OpenAPI 3.1 nullable compatibility

Open Beginner friendly
#616 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
openapi, typescript
Domain
api, frontend

Research direction

Start in src/openapi/schemaAnalyzer.ts around the linked schema analyzer entry point and inspect how a schema whose type includes null is handled. Validate the analyzer with the provided integer-and-null example; done means it reports integer rather than string so components such as InputGuesser receive the correct input type.

Written by the indexing model from the issue text.

Description

Description
OpenAPI 3.1 specification defines Schemas properties nullable types as described below to follow JSON Schema 4.

API Platform Admin openAPI schema Analyzer does not process nullable type and fallback to string type instead of extracting type from the non-nullable type. This introduces wrong input type when using Component like InputGuesser for example.

Schema Analyzer should take into account nullable types.

Example

# OpenAPI specification example
[…]
properties:
    myProperty:
        type:
            - integer
            - null

# Before fix
schemaAnalyze field type is `string`

# After fix
schemaAnalyzer field type is `integer`
Dominant language
TypeScript
Stars
516
Forks
134
PR merge metrics
No merged PRs in 30d

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.

More from api-platform/admin

All issues in api-platform/admin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.