I am able to generate restdocs for rest services which is created by me, but unable to generate docs for services which i am consuming.
Is there any way to test and generate docs for third party API.
Sample code which i am using to generate to docs for local services.
@RunWith(SpringRunner.class)
@WebAppConfiguration
@SpringBootTest(classes = RestdocApplication.class)
public class CountryDocumentation {
private static final Logger logger =
LoggerFactory.getLogger(CountryDocumentation.class);
private MockMvc mockMvc;
@Autowired
private WebApplicationContext context;
@Rule
public final JUnitRestDocumentation restDocumentation = new
JUnitRestDocumentation("target/generated-snippets");
@Mock
private CountryService countryService;
@Mock
private RestTemplate restTemplate;
@Before
public void setUp() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).apply(documentationConfiguration(this.restDocumentation)
.uris().withHost("X.X.X.X").withPort(9090).and().operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())).defaultRequest(get("/")).build();
}
@Test
public void getCountryDefinition() throws Exception {
this.mockMvc.perform(get("/"))
.andExpect(status().is(200))
.andDo(document("{ClassName}/{methodName}"));
}
}