Forum Discussion
rajrahul9939
Occasional Contributor
Hey HKosova
swagger-inflector, only works when the schema is defined, Here is more details about my query.
I have an API "/hello" defined below.
and Person class like below.
I wanted to generate a response example like below.
Thank you.
rajrahul9939
5 years agoOccasional Contributor
Hey HKosova ,
could you please help
- HKosova5 years agoSmartBear Alumni (Retired)
rajrahul9939 wrote:
swagger-inflector, only works when the schema is defined
ExampleBuilder does not necessarily need a named schema; it can use any schema, including those defined inline - you just need to pass in the appropriate parameters. And the parser has methods to get the response schema for a specific path, HTTP method, and response code
In your case, to generate an example for the path /hello, method GET, and HTTP status 200 you can use:
Model responseSchema = swagger.getPath("/hello")
.getOperationMap().get(HttpMethod.GET)
.getResponses().get("200")
.getResponseSchema(); Example example = ExampleBuilder.fromModel(null, responseSchema, definitions, new HashSet<String>());The rest of the code is the same as here.
Related Content
- 2 years agovericomms
- 2 months agoNicolaFilosa_SE
- 2 years agoTauras
Recent Discussions
- 15 hours agonoob_Vibes