swagger-api / swagger-api/swagger-parser

Parsing error with object default value when the nullable true enable

Open
#2,050 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Hi Team,

I'm using OpenAPIV3Parser to get openAPI specifications for the parser version 2.1.16. I am wondering when I used the default value as a null for the object type which is enabled nullable true. It returns below parser issues[1].
is there any particular reason we can not have null as the default in the object type when it is nullable true?

[1] parser issue

attribute components.schemas.CreateChatCompletionRequest.default is not of type `object`

example code logit_bias field has object type with nullable true enable:

CreateChatCompletionRequest:
      type: object
      properties:
        ...
        logit_bias:
          type: object
          x-oaiTypeLabel: map
          default: null
          nullable: true
          additionalProperties:
            type: integer

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

Start by reproducing the parser issue with the supplied CreateChatCompletionRequest schema and OpenAPIV3Parser version 2.1.16. Trace the validation of the object default and nullable setting; done means the behavior for a nullable object with a null default is defined and covered by an appropriate parser check.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.