3
  1. OpenAPI client generation module generates client-code(ApiClient-RestTemplate and APISpecificClient which uses ApiClient)
  2. The contract is always strict. Ex: I have to specify in:header in:path in:query for the etc... for API request and response.
  3. My requirement is apart from what the yml-contract says, I need to send additional headers as part of request. This is needed because sometimes engineers expect new-headers as part of their API and they don't update APISpec or Architect decides to ignore common-used-headers(Architect specifies additional headers are mentioned in WIKI).
  4. Simple solution is, as a Engineer I can update the yml-contract and all good to go.
  5. Alternate best solution is, if the ApiClient-APISpecificClient(codegen) accepts a additional header as Map, it solves a lot of problem... Note1: ApiClient supports addDefaultHeader, but this is wrong. Because value for defaultHeader is specific to each request, so I cannot use this. Note2: I can create new object of ApiClient/APISpecificClient for each request instead of "Component", this also solves the problem. But I feel it is heavy to create objects.

Any help would be appreciated.

1 Answers1

1
  1. Using RestTemplateInterceptor added additional headers... https://www.baeldung.com/spring-rest-template-interceptor
  2. Another solution is AOP.
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 19 '22 at 03:40