Linter problem with `oneOf` and integer
See original GitHub issueI’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:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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! 😃