Giving an integer value as default for a double, causes the validation to fail
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 42/100
Rechercherichtung
Reproduce the failure with the provided openapi.yaml using openapi_spec_validator.readers.read_from_filename and validate_spec. Compare validation of integer and floating-point defaults for a number with format double; done means the intended behavior is established and covered by a regression test, while preserving the valid 15.0 case.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Hi,
I noticed that there is a breaking change from 0.2.9 to 0.3.0, but I am not sure if it is intentional or not.
tl;dr: an integer is no longer considered a valid (default) value for a double. In the example below, 15 fails the validation, but 15.0 is fine.
PS: I am using openapi-spec-validator through the connexion library.
Steps to reproduce
python -m venv .venv
source .venv/bin/activate
pip install "openapi-spec-validator@0.3.0"
>>> from openapi_spec_validator import validate_spec
>>> from openapi_spec_validator.readers import read_from_filename
>>>
>>> spec_dict, spec_url = read_from_filename('./openapi.yaml')
>>> validate_spec(spec_dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<current working directory>/.venv/lib/python3.9/site-packages/openapi_spec_validator/shortcuts.py", line 7, in validate
return validator_callable(spec, spec_url=spec_url)
File "<current working directory>/__app__/.venv/lib/python3.9/site-packages/openapi_spec_validator/validators.py", line 48, in validate
raise err
openapi_spec_validator.exceptions.OpenAPIValidationError: 15 is not a 'double'
Failed validating 'format' in schema:
{'default': 15,
'format': 'double',
'maximum': 60,
'minimum': 15,
'nullable': False,
'type': 'number'}
On instance:
15
where openapi.yaml is defined as
openapi: "3.0.3"
info:
title: API
version: "1.0.0"
servers:
- url: http://localhost/api
description: Used for local development.
paths:
/foo:
get:
parameters:
- in: query
name: duration
required: false
schema:
type: number
format: double
default: 15
maximum: 60
minimum: 15
example: 53
responses:
200:
description: ""
content:
text/plain: {}
Changing default: 15 to default: 15.0 works as expected.
In version 0.2.9, the OpenAPI specification above was considered valid.
- Vorherrschende Sprache
- Python
- Sterne
- 409
- Forks
- 73
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-openapi/openapi-spec-validator
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 30/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 42/100
python-openapi/openapi-spec-validator#400 · 1 Kommentar ·
-
kind/bug/confirmed
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
python-openapi/openapi-spec-validator#373 · 1 Kommentar ·
Alle Issues in python-openapi/openapi-spec-validator
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
anthropics/skills#1811 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
speaches-ai/speaches#678 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
datalayer/mcp-compose#42 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
conda-forge/spacy-feedstock#177 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
UKGovernmentBEIS/inspect_evals#2523 ·