swagger-api / swagger-api/swagger-core
Endpoint where the request body is an extended class is not generated in swagger.json
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached sample-webapp Maven project, run mvn clean package, and compare the generated swagger.json for ExtendedResource with the SimpleResource examples. Trace how inherited resource and request-body classes are processed; done means the PUT and POST operations for /sample/extended appear in the generated specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100