swagger-core
swagger-core copied to clipboard
Endpoint where the request body is an extended class is not generated in swagger.json
Please refer to the attached sample maven project and result swagger.json.
swagger.json sample-webapp.zip
Description
Class ExtendedResource extends AbstractResource (which implements ResourceInterface).
Class ExtendedResource defines 3 REST commands, on the same endpoint "sample/extended": GET, PUT, POST
The PUT and POST endpoints have request body of type ExtendedData. Class ExtendedData extends AbstractData.
In the resulting swagger.json, only GET is generated for resource "/sample/extended" :
"/sample/extended" : { "get" : { "tags" : [ "extended data resource" ], "description" : "Retrieve extended data.", "operationId" : "get", "responses" : { "200" : { "description" : "Normal response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/extendedData" } }, "application/xml" : { "schema" : { "$ref" : "#/components/schemas/extendedData" } } } } } } }
Notes
If either the request body class or the resource class is not an extended class, then all REST commands are generated in swagger.json, as shown by the examples using class SimpleData, and class SimpleResource.
See also the fixed bug: https://github.com/swagger-api/swagger-core/issues/3694
Swagger Version
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core-jakarta</artifactId>
<version>2.2.25</version>
</dependency>
Other dependencies versions : refer to pom.xml in the attached project.
To Reproduce
- Unzip sample-webapp.zip
- Run : mvn clean package
- Observe the resulting swagger.json in target/sample-webapp-0.0.1-SNAPSHOT/swagger