OpenAPITools / OpenAPITools/openapi-generator

[REQ] Add parameter to standardize handling null types in all language

Open
#12,257 29 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

this is a problem that happens when a property has no default value, and is marked non-required and non-nullable
related: https://github.com/OAI/OpenAPI-Specification/discussions/2807

Describe the solution you'd like

  1. Add a new parameter for all language generators (e.g. handlingStrategyForNonNullableNonRequired)
  2. Its possible values are:
    1. FALLBACK old behavior so we won't cause a breaking change
    2. assumeNullable assume that it's nullable
    3. assumeRequired , assume that it's required
    4. assumeDefault , assumes a default value based on the clr (e.g. in c# that would be default(T) , in js it would be undefined)
    5. raiseError prevents handling this case altogether
  3. languages will then opt-in to handle this new parameter by specifying in the FEATURE SET what of the 5 values they support (All languages will support fallback, raiseError, assumeNullable,assumeRequired by default, since they can be handled globally)

I can start working on the implmentation if someone can point me in the right direction
@wing328

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by tracing how language generators declare their FEATURE SET and how non-required, non-nullable properties are handled, then read the linked OpenAPI discussion for the underlying case. Done means the proposed parameter and its five values have defined support across the relevant generators without changing the fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.