Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"default: null" on non nullable object isn't considered as an error #4479

Open
gturri opened this issue Oct 10, 2023 · 0 comments
Open

"default: null" on non nullable object isn't considered as an error #4479

gturri opened this issue Oct 10, 2023 · 0 comments

Comments

@gturri
Copy link

gturri commented Oct 10, 2023

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Firefox
  • Version: 118.0.1 (64 bits)
  • Method of installation: Not installed: I'm using it directly from https://editor-next.swagger.io/
  • Swagger-Editor version: 5.0.0-alpha78
  • Swagger/OpenAPI version: OpenApi 3.0.3

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
 title: test
 version: v0.1
 description: test
paths:
 /api/path:
  get:
   responses:
    '200':
      description: ok
      content:
       application/json:
        schema:
         $ref: '#/components/schemas/MyEntity'
components:
 schemas:
  MyEntity:
   type: object
   properties:
    someField:
     type: array
     items: 
       type: string
     default: null

Describe the bug you're encountering

default– the default value must conform to the specified schema.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/
  2. Copy / paste the spec above

Expected behavior

An error saying that the default value cannot be null, is detected

Screenshots

As shown on this screenshot: in practice I don't have any error
image

Additional context or thoughts

FTR: OpenApiGenerator does detect that error: when I run OpenApiGenerator CLI like this

java -jar openapi-generator-cli-7.0.1.jar generate --generator-name csharp --input-spec my_spec.yaml --output out_dir 

it fails with message

Errors:                                                                      
        -attribute components.schemas.MyEntity.default is not of type `array`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant