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

Example value as null fails #2649

Open
benjamin-mogensen opened this issue Jul 3, 2024 · 0 comments
Open

Example value as null fails #2649

benjamin-mogensen opened this issue Jul 3, 2024 · 0 comments

Comments

@benjamin-mogensen
Copy link

Describe the bug
When OpenAPI specification contains null as an example value the Spectral engine reports Cannot read properties of null (reading 'type')

To Reproduce

  1. Run Spectral validation on the following OAS:
openapi: 3.0.0
info:
  version: 1.0.0
  title: Cat
  description: Cat API
  contact:
    name: Cat owner
    email: [email protected]
    url: https://developer.cats.com/contact-us
  license:
    url: https://www.cats.com/api-license-terms
    name: Cats 1.0
servers:
  - url: https://api.maersk.com/products
    description: Production Environment
paths:
  /cats:
    get:
      operationId: get-cats
      description: Cats
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
                nullable: true
                example: null

Expected behavior
It is expected that null is an allowed example value for nullable properties.

CLI Environment:

  • Spectral CLI version: 6.11.1
  • OS: Mac

CLI Environment Output

(node:46129) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error running Spectral!
Use --verbose flag to print the error stack.
Error #1: Cannot read properties of null (reading 'type')

Node.js Environment

  • @stoplight/spectral-core 1.18.3
  • @stoplight/spectral-parsers 1.0.3
  • @stoplight/spectral-ruleset-bundler 1.5.2
  • @stoplight/spectral-rulesets 1.19.0
  • @stoplight/spectral-runtime 1.1.2

Node.js Environment Output
image

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