Skip to content

Lint rules for examples require exclusiveMinimum to be number in openapi 3.0.x #1610

@gtsystem

Description

@gtsystem

Describe the bug

The linter is returning the error Example validation errored: exclusiveMinimum value must be ["number"], however in openapi 3.0.x exclusiveMinimum must be of type boolean, not number.

To Reproduce
Steps to reproduce the behavior:

  1. Given the following openapi file:
openapi: 3.0.2
info:
  title: Example API v2
  description: |-
    An  example API.
  contact: {}
  version: 2.0.0

paths:
  /myPath:
    get:
      summary: my custom path
      operationId: getMyPath
      parameters:
        - $ref: '#/components/parameters/a'
      responses:
        '200':
          description: Response description
          content:
            application/json:
              schema: {}

components:
  parameters:
    a:
      name: a
      in: header
      description: Example 
      schema:
        type: integer
        minimum: 10
        exclusiveMinimum: true
        example: 11
  1. And the lint configuration:
rules:
  no-invalid-schema-examples: error
  1. Run this command
    npx @redocly/cli lint openapi-example.yml --config openapi-example.conf.yml --format=stylish

  2. See error

(node:53722) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
validating /.../openapi-example.yml:
  30:9  error    no-invalid-schema-examples  Example validation errored: exclusiveMinimum value must be ["number"].

openapi-example.yml: validated in 12ms

❌ Validation failed with 1 error.
run `redocly lint --generate-ignore-file` to add all problems to the ignore file.

Expected behavior

The validation pass, because in openapi 3.0.x exclusiveMinimum MUST be of type boolean and is defined correctly.
This is different in openapi 3.1.0, but the specification provided is for 3.0.2.

Redocly Version(s)

1.17.1

Node.js Version(s)

22.2.0

Additional context

Same issue is present using no-invalid-parameter-examples rule.
See also changes between 3.0.x and 3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions