How can I use my own annotation for building swagger ui page. For example I defined annotation and use it:
@PUT
@MyOwnAnnotationForAdditionalPropInSwagger(value = "Some text")
@Path( "/{carId}" )
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Updates car info"
)
public Response patchItem(@ApiParam(value = "Fields to update") Car item) {
/*some code*/
}
After that probably I should extend some class from swagger-core
and specify to scan my annotation (@MyOwnAnnotationForAdditionalPropInSwagger
).
As result I want to see additional column in swagger ui with my text.
How I can realize it? What class I need to extend?
The swagger 2.0 supports custom fields, there was a Pull Request for this back in 2013 (https://github.com/swagger-api/swagger-node/pull/47).
While apparently it's easy to add the custom fields, since they are not present in the Swagger 2.0 spec, Swagger-UI won't display them by default.
For this to work you will have to change a couple of things.
swagger-core
or swagger-php
) if it doesn't exist.swagger-ui
to display your custom field as you wish.Note that by doing this you will in fact violate the swagger json schema (https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json) and any third party validators you may use will fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With