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

Duplication of results #680

Closed
nulltoken opened this issue Oct 13, 2019 · 1 comment · Fixed by #681
Closed

Duplication of results #680

nulltoken opened this issue Oct 13, 2019 · 1 comment · Fixed by #681
Assignees
Labels
t/bug Something isn't working

Comments

@nulltoken
Copy link
Contributor

nulltoken commented Oct 13, 2019

Describe the bug

It's not uncommon to use a file (or a set of files) that acts as a "library" of reusable things.
When an error happens in that file, it looks like it gets reported multiple times.

To Reproduce

  1. Given this OpenAPI document '...'

repro/lib.yaml

openapi: 3.0.0

info:
  title: Lib
  version: "1"
  description: I'm here
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com

servers:
  - url: http://api.example.com/v1

paths: {}

components:
  schemas:
    Test:
      type: integer
      example: "13"

repro/A.yaml

openapi: 3.0.0

info:
  title: Title
  version: "1"
  description: I'm here
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com

servers:
  - url: http://api.example.com/v1

paths:
  "/resource":
    get:
      description: fetch
      operationId: "12"
      tags: ["a"]
      responses:
        "200":
          description: Coolio
          content:
            application/json:
              schema:
                $ref: "./lib.yaml#/components/schemas/Test"

repro/B.yaml

openapi: 3.0.0

info:
  title: Title
  version: "1"
  description: I'm here
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com

servers:
  - url: http://api.example.com/v1

paths:
  "/resource":
    get:
      description: fetch
      operationId: "12"
      tags: ["a"]
      responses:
        "200":
          description: Coolio
          content:
            application/json:
              schema:
                $ref: "./lib.yaml#/components/schemas/Test"

repro/C.yaml

openapi: 3.0.0

info:
  title: Title
  version: "1"
  description: I'm here
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com

servers:
  - url: http://api.example.com/v1

paths:
  "/resource":
    get:
      description: fetch
      operationId: "12"
      tags: ["a"]
      responses:
        "200":
          description: Coolio
          content:
            application/json:
              schema:
                $ref: "./lib.yaml#/components/schemas/Test"

Note: A.yaml, B.yaml and C.yaml share the same content for sake of easily building a repro case.

  1. Run this CLI command '....'
$ yarn spectral lint "./repro/*.yaml"
yarn run v1.15.2
$ C:\node_modules\.bin\spectral lint ./repro/*.yaml
  1. See error
OpenAPI 3.x detected
OpenAPI 3.x detected
OpenAPI 3.x detected
OpenAPI 3.x detected

c:/repro/lib.yaml
 21:16  error  valid-schema-example-in-content  "schema.example" property type should be integer
 21:16  error  valid-schema-example-in-content  "schema.example" property type should be integer
 21:16  error  valid-schema-example-in-content  "schema.example" property type should be integer
 21:16  error  valid-example-in-schemas         "Test.example" property type should be integer

✖ 4 problems (4 errors, 0 warnings, 0 infos, 0 hints)

Expected behavior
Deduplicating the errors would

  • Reduce the noise from the report and make it easier to work through
  • Reduce the number of true root-cause errors (and potentially help reducing the stress level of the average middle manager inspecting some random KPIs)

Environment (remove any that are not applicable):

  • Library version: 4.2.0
  • OS: Windows 3.11 (nah... I'm just kidding)
@nulltoken nulltoken added the t/bug Something isn't working label Oct 13, 2019
@P0lip
Copy link
Contributor

P0lip commented Oct 14, 2019

valid-schema-example-in-content
Seems like an issue with that rule. I'll take a look.

Ah, no, it's due to resolving. We basically lint the same node against the same rule more than once.

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.

2 participants