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-media-example is reported for primitives if type is object #2592

Open
gssbzn opened this issue Feb 28, 2024 · 0 comments
Open

oas3-valid-media-example is reported for primitives if type is object #2592

gssbzn opened this issue Feb 28, 2024 · 0 comments
Labels
OpenAPI Issues related to the OpenAPI ruleset p/medium t/bug Something isn't working

Comments

@gssbzn
Copy link

gssbzn commented Feb 28, 2024

Describe the bug
According to https://spec.openapis.org/oas/v3.0.3#schema-object object can also be primitive values but spectral seems to flag examples using primitives as invalid

To Reproduce

  1. Given this this schema
schema:
    ApiError:
      type: object
      properties:
        detail:
          type: string
        error:
          type: integer
          format: int32
        parameters:
          type: array
          description: Parameter used to give more information about the error.
          items:
            type: object            

an example like

          example:
            error: 400
            detail: "Example"
            parameters:
            - "0"
  1. Run this CLI command spectral lint with the default extends: [spectral:oas] rule sets
  2. See error
error  oas3-valid-media-example  "0" property type must be object  components.responses.badRequest.content.application/json.example.parameters[0]

Expected behavior
Object examples should accept primitives according to the spec

Environment (remove any that are not applicable):

  • CLI version 6.11.0
@mnaumanali94 mnaumanali94 added t/bug Something isn't working OpenAPI Issues related to the OpenAPI ruleset p/medium labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenAPI Issues related to the OpenAPI ruleset p/medium t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants