OpenAPITools / OpenAPITools/openapi-generator
[REQ] Is there a way to prevent user from being able to push body boolean attribut = null
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I've described in my openApi that a boolean field is optional, and the default value is false, because most ppl do not need to care about this argument.
I've defined a default value, and it worked great until a customer sent an explicit null value.
Can I do anything so that the request with null value will be either rejected or the default value will be injected with default value ?
I'm using java code behind and would like to avoid having to do manual boolean check on everything, any chance to generate primitve boolean otherwise ?
Also, can I do anything to prevent null objects in array attribut, without having to check manual in my code ?
Either by removing null value, or throwing an error when user try to push a null item in an array ?
For both I've tried to use openApi "nullable: false" but doesnt seems help.
Describe the solution you'd like
Allow to use primitive boolean for some boolean flag, or take into account nullable: false by injecting default value or throwing a validation exception
Describe alternatives you've considered
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
No files, tests, or entry points are named. Start by examining how OpenAPI nullable and default values are handled for generated Java booleans and array items; done would mean an agreed behavior for rejecting nulls or applying defaults without manual checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100