question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linter problem with `oneOf` and integer

See original GitHub issue

I’m submitting a…

  • bug report
  • feature request

What is the current behavior?

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  description: Swagger Petstore
  license:
    name: MIT
  contact:
    name: Test
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      description: Get a pet
      tags:
        - pets
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  oneOf:
                    - type: string
                    - type: number
                    - type: integer
                example:
                  a_property: 1234567890
$ spectral lint ~/Development/spectral-error.yml
Adding OpenAPI 3.x functions
OpenAPI 3.x detected

/home/juanignaciosl/Development/spectral-error.yml
 25:22  warning  valid-example  "a_property" property should be string
 25:22  warning  valid-example  "a_property" property should match exactly one schema in oneOf

✖ 2 problems (0 errors, 2 warnings, 0 infos)

What is the expected behavior?

$ spectral lint ~/Development/spectral-error.yml
Adding OpenAPI 3.x functions
OpenAPI 3.x detected
No errors or warnings found!

In fact, if you remove the - type: integer section, you get it right.

What is the motivation / use case for changing the behavior?

It’s a bug.

Please tell us about your environment:

$ spectral --version
@stoplight/spectral/3.1.0 linux-x64 node-v8.14.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
philsturgeoncommented, Jul 5, 2019

Hey @juanignaciosl thanks for the bug report! This is actually fixed already in the develop branch which will be released in the next few days as v4.0. It’s part of #265.

We will hopefully have a beta tagged for you today that you can play with.

0reactions
juanignacioslcommented, Jul 8, 2019

Oh, I see! Thank you very much for the explanation, you’re totally right, I didn’t know that.

About the linter, I’d say that the first message (a_property" property type should be string) is not accurate and misleading, because it should be “just one of string, number or integer”, maybe that could be improved.

Anyway, I’ll close this, thank you very much! 😃

@XVincentX yep, I know Iago from CARTO, but he’s no longer here. I’m based in Valladolid, remote FTW! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building an OpenAPI response, including oneOf, and maybe ...
I tried a $ref , but it didn't work. The below successfully passes three different OpenAPI linting tools, but in the example it...
Read more >
typescript-eslint fastcheck oneof any error - You.com | The AI ...
When I run eslint: lint whole folder task, it fails because of the error mentioned ... ts function smallest<T extends oneof(string, number)>(x: T[]):...
Read more >
Formatters - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
SimpleSchema (simpl-schema NPM package)
Powerful customizable error message system with decent English language defaults and support for localization, which makes it easy to drop this ...
Read more >
JSON Schema Validation
JSON Schema Validation, in browser, using ajv, with linting, and shareable schemas. ... Validation Error. should match exactly one schema in oneOf.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found