OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java] required fields are not validated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Currently when I define required fields in the api.yaml, they are not validated in the generated classes.
It returns a HTTP 200 OK and proceeds, instead of returning HTTP 405 invalid input
Actual:
you can find the example project here: https://github.com/bobocu/openapi-demo
POST localhost:8091/api/v1/pet
body: { "test": "test" }
return HTTP 200 OK and defined log message is displayed in sysout.
openapi-generator version
5.1.0
OpenAPI declaration file content or url
just use the default petstore yaml
https://github.com/bobocu/openapi-demo/blob/master/src/main/resources/static/api.yaml
Generation Details
execute openApiGenearte
import spring boot gradle project and start on local machine
Steps to reproduce
execute POST request to localhost:8091/api/v1/pet
with various json body
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 default Petstore api.yaml and the example Spring Boot Gradle project at bobocu/openapi-demo, then reproduce POST /api/v1/pet with the incomplete JSON body. Inspect the generated classes and request handling; the work is done when required fields are validated and the request no longer returns HTTP 200 OK.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100