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

oas3-valid-(content-)schema-example: Problem with nullable #894

Closed
m-mohr opened this issue Jan 7, 2020 · 0 comments · Fixed by #914
Closed

oas3-valid-(content-)schema-example: Problem with nullable #894

m-mohr opened this issue Jan 7, 2020 · 0 comments · Fixed by #914
Labels
t/bug Something isn't working

Comments

@m-mohr
Copy link
Contributor

m-mohr commented Jan 7, 2020

Describe the bug

It seems that in some cases the rules oas3-valid-schema-example and oas3-valid-content-schema-example fail although the examples are valid. Seems to be an issue with nullable / null values.

I get in the command line:

  59:33  error  oas3-valid-content-schema-example  `1` property type should be string
 167:25  error  oas3-valid-content-schema-example  `1` property type should be string
 167:25  error  oas3-valid-schema-example          `1` property type should be string

To Reproduce

OpenAPI document openapi.yaml:

openapi: 3.0.2
info:
  version: 1.0.0
  title: openEO API
  description: ...
  contact:
    name: openEO Consortium
    url: 'http://www.openeo.org'
    email: [email protected]
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
  - name: EO Data Discovery
    description: ...
servers:
  - url: 'https://localhost/api'
    description: ...
paths:
  /collections:
    get:
      summary: Basic metadata for all datasets
      operationId: list-collections
      description: ...
      tags:
        - EO Data Discovery
      responses:
        '200':
          description: A list of collections and related links.
          content:
            application/json:
              schema:
                title: Collections Response
                type: object
                required:
                  - collections
                properties:
                  collections:
                    type: array
                    items:
                      $ref: '#/components/schemas/collection'
                example:
                  collections:
                    - extent:
                        temporal:
                          interval:
                            - - '2000-02-01T00:00:00Z'
                              - null
components:
  schemas:
    collection:
      title: STAC Collection
      type: object
      required:
        - extent
      properties:
        extent:
          type: object
          title: STAC Collection Extent
          description: ...
          required:
            - spatial
            - temporal
          properties:
            temporal:
              description: The *potential* temporal extent of the features in the collection.
              type: object
              properties:
                interval:
                  description: ...
                  type: array
                  minItems: 1
                  items:
                    description: ...
                    type: array
                    minItems: 2
                    maxItems: 2
                    items:
                      type: string
                      format: date-time
                      nullable: true
                    example:
                      - '2011-11-11T12:22:11Z'
                      - null

.spectral.yml

extends: "spectral:oas"

Run: spectral lint openapi.yaml

Expected behavior

No warnings/errors

Environment (remove any that are not applicable):

  • Library version: 5.0.0
  • OS: Windows 10
@m-mohr m-mohr added the t/bug Something isn't working label Jan 7, 2020
@m-mohr m-mohr changed the title oas3-valid-content-schema-example: Problem with nullable oas3-valid-(content-)schema-example: Problem with nullable Jan 7, 2020
P0lip added a commit that referenced this issue Jan 20, 2020
)

* First attempt to fix #894: oas3-valid-(content-)schema-example has problem with nullable

* Use OpenAPI schemas

* Don't use OpenAPI schemas

* Set default oasVersion

* Use optional instead of 0.

* Fix annoying lint rule

* Update src/functions/schema.ts

Co-Authored-By: Jakub Rożek <[email protected]>

Co-authored-by: Jakub Rożek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant