spring-restdocs

Duplicate Request Parameters being recorded in the snippet [duplicate]

a 夏天 提交于 2019-12-12 02:25:42
问题 This question already has answers here : RestDocs does double documentation on request parameters (2 answers) Closed 3 years ago . As the title suggests I have a Controller endpoint I'm trying to document. The endpoint can take 2 parameters both are optional. When it goes to generate the code the parameter is duplicated. Controller @RequestMapping("/bitbucket/project") public Project findProject(@RequestParam(value = "key", required = false) String key, @RequestParam(value = "name", required

Utilize Spring Restdocs DSL for validation

自古美人都是妖i 提交于 2019-12-11 04:14:41
问题 our REST API is documented by set of tests using Spring Restdocs in standard way (via mockMvc.perform(...)...andDo(document().fieldWithPath(...)) statement. Since fields have type and mandatory/optional flag, I play with idea to reuse this info for purpose of response body validation also in production code. I moved Spring Restdocs to compile Maven scope and moved snippet creation to production code where it is visible for both the documenting test and response body interceptor in src/main

Spring Rest Doc not producing html

自古美人都是妖i 提交于 2019-12-10 12:56:37
问题 I followed the getting started guide for Spring Rest Doc word by word, but I cannot get any html out of the generated snippets. The snippets are generated fine in the directory I configure ( build/generated-snippets ), but I can't see any html5/ directory with html files generated out of the snippets. The doc at some point says what to do to package the documentation in the jar, and it's clear that it expects some files in an html5/ directory, but this is not created when the build runs:

java.lang.AssertionError: Status expected:<200> but was:<404> in Junit test

北城以北 提交于 2019-12-06 06:04:16
I want to create JUnit test for Rest api and generate api doc. I want to test this code: Rest controller @RestController @RequestMapping("/transactions") public class PaymentTransactionsController { @Autowired private PaymentTransactionRepository transactionRepository; @GetMapping("{id}") public ResponseEntity<?> get(@PathVariable String id) { return transactionRepository .findById(Integer.parseInt(id)) .map(mapper::toDTO) .map(ResponseEntity::ok) .orElseGet(() -> notFound().build()); } } Repository interface public interface PaymentTransactionRepository extends CrudRepository

RestDocs does double documentation on request parameters

亡梦爱人 提交于 2019-12-02 14:05:06
问题 Using RestDocs version 1.1.1.RELEASE and SpringBoot 1.4.0.RELEASE, parameters when using "httpRequest" is documented double. The following code: @RunWith(SpringRunner.class) @WebMvcTest(ProductResource.class) @AutoConfigureRestDocs("target/generated-snippets") public class ProductResourceDocumentation { private static final String PROPERTY_ID_VALUE = "d7612"; private static final String SALES_MARKET_VALUE = "999"; private static final String SEASON_VALUE = "2016"; private static final String

RestDocs does double documentation on request parameters

◇◆丶佛笑我妖孽 提交于 2019-12-02 04:35:46
Using RestDocs version 1.1.1.RELEASE and SpringBoot 1.4.0.RELEASE, parameters when using "httpRequest" is documented double. The following code: @RunWith(SpringRunner.class) @WebMvcTest(ProductResource.class) @AutoConfigureRestDocs("target/generated-snippets") public class ProductResourceDocumentation { private static final String PROPERTY_ID_VALUE = "d7612"; private static final String SALES_MARKET_VALUE = "999"; private static final String SEASON_VALUE = "2016"; private static final String SECTIONS_VALUE = "buildings"; private static final String SHOW_DESCRIPTIONS_VALUE = "false"; private

Spring REST mock context path

痞子三分冷 提交于 2019-12-02 01:23:12
问题 I try to set the context path for spring rest mocks using the following code snippet: private MockMvc mockMvc; @Before public void setUp() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(documentationConfiguration(this.restDocumentation)) .alwaysDo(document("{method-name}/{step}/", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) .build(); } @Test public void index() throws Exception { this.mockMvc.perform(get("/").contextPath("/api").accept

Spring REST mock context path

﹥>﹥吖頭↗ 提交于 2019-12-01 22:18:43
I try to set the context path for spring rest mocks using the following code snippet: private MockMvc mockMvc; @Before public void setUp() { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(documentationConfiguration(this.restDocumentation)) .alwaysDo(document("{method-name}/{step}/", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) .build(); } @Test public void index() throws Exception { this.mockMvc.perform(get("/").contextPath("/api").accept(MediaTypes.HAL_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("_links.business-cases", is

How to search via Json in elastic search using spring resttemplate in android

北城以北 提交于 2019-11-28 00:36:35
Hi i am trying to search data in elastic search using spring RestTemplate. ElasticSearch have user name and password and i want to search via json. I wrote code for this but i am not getting any result or exception. I am doing this for the first time in my life so sorry if there is some silly mistake in it. @Override protected List<JobPosts> doInBackground(Object[] objects) { List list = null; try { SearchForm searchForms = (SearchForm) objects[0]; String plainCreds = "******:********"; final String url = "*******"; RestTemplate restTemplate = new RestTemplate(); restTemplate

How to search via Json in elastic search using spring resttemplate in android

人盡茶涼 提交于 2019-11-27 04:45:25
问题 Hi i am trying to search data in elastic search using spring RestTemplate. ElasticSearch have user name and password and i want to search via json. I wrote code for this but i am not getting any result or exception. I am doing this for the first time in my life so sorry if there is some silly mistake in it. @Override protected List<JobPosts> doInBackground(Object[] objects) { List list = null; try { SearchForm searchForms = (SearchForm) objects[0]; String plainCreds = "******:********"; final