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

Examples for recursive object types aren't validated #2548

Open
belka-ew opened this issue Oct 18, 2023 · 0 comments
Open

Examples for recursive object types aren't validated #2548

belka-ew opened this issue Oct 18, 2023 · 0 comments
Labels
enhancement New feature or request triaged

Comments

@belka-ew
Copy link

Describe the bug
Examples for recursive object types aren't validated.

To Reproduce

.spectral.yaml

extends:
  - [spectral:oas, recommended]
rules:
  info-contact: off
  oas3-api-servers: off
  operation-description: off
  oas3-valid-schema-example: true

api.yaml

openapi: 3.0.0

info:
  version: 1.0.0
  title: Title
  description: Description

paths:
  /:
    post:
      tags:
        - Tags
      operationId: operation

      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                external:
                  $ref: "#/components/schemas/A"
              example:
                external: A-1
      responses:
        "201":
          description: Created

tags:
  - name: Tags

components:
  schemas:
    A:
      type: object
      properties:
        internal:
          $ref: "#/components/schemas/A"
  1. Run this CLI command ./spectral lint api.yml.
  2. Produces no error.

Expected behavior
Replacing the $ref in A.internal with type: number produces an error:

24:27 error oas3-valid-schema-example "external" property type must be object paths./.post.requestBody.content.application/json.schema.example.external

But this doesn't happen for an object as in the example above.

Environment:

  • Library version: 6.11.0
  • OS: Slackware Linux 15.0
  • Platform: 64 bit
@mnaumanali94 mnaumanali94 added the enhancement New feature or request label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

2 participants