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

type array list not validated in OAS 3.1 #856

Closed
adamaltman opened this issue Sep 7, 2022 · 1 comment · Fixed by #891
Closed

type array list not validated in OAS 3.1 #856

adamaltman opened this issue Sep 7, 2022 · 1 comment · Fixed by #891
Assignees
Labels
p1 Type: Bug Something isn't working

Comments

@adamaltman
Copy link
Member

adamaltman commented Sep 7, 2022

Describe the bug

When a schema has type null defined in YAML, it is being treated as a null value and not "null" the string that defines the types.

https://json-schema.org/understanding-json-schema/reference/null.html

https://github.com/Redocly/openapi-starter/blob/main/openapi/components/schemas/Schema.yaml#L41

I believe that Schema needs to be adjusted to the following to define the type properly:

  nullableOrStringProperty:
    description: Property name's description (type is string or null)
    type:
      - string
      - "null"

However, I then suspected that nothing in the type list is being validated:

Redocly/openapi-starter#74

This bug does not exist when type is defined as a string (for example the following would produce a problem):

type: foo

To Reproduce
Steps to reproduce the behavior:

  1. See bug: reproduce a bad type openapi-starter#74
  2. See error (that there is no problem)

Expected behavior

problem message:

type can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".

Logs

There is no problem detected (which is the problem because there is a problem).

OpenAPI definition

OAS 3.1
https://github.com/Redocly/openapi-starter/blob/main/openapi/components/schemas/Schema.yaml#L41

Redocly Version(s)

1.0.0-beta.108

Node.js Version(s)

16.10

Additional context

  • This was revealed by some crashing of our mock server.
@razvanphp
Copy link

Hmm, interesting, so my schema is invalid? null needs to always be defined as a string? Why?

allOf:
  - type: object
    properties:
      car:
        $ref: ./Car.yaml
      user:
        type:
          - object
          - null
        $ref: ./User.yaml
      user_id:
        type:
          - integer
          - null
      car_id:
        type:
          - integer
          - null

This was not triggering an error on 1.0.0-beta.125, but it does now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants