No specific error information available.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Reproduce the validation with the provided model.yaml and validate_v30_spec(spec_dict), then inspect how OpenAPIValidationError and the iterator expose jsonschema failures. Trace the reported response error back to components/schemas/Pet/properties/id, and consider the work complete when that invalid additional property is identified in the resulting error.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
First of all, I'm focussing on validating models (components/schemas) in an OpenAPI 3.0.0. yaml file.
I'm testing with a slightly changed petstore.yaml (keep an eye on components/schemas/Pet/properties/id which has an extra attribute min instead of minimal):
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
200:
description: An paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
min: 1
type: integer
format: int64
name:
type: string
tag:
type: string
$ref:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Swagger Editor reports nicely on that little "typo" in pet's property id:

No matter what I try with openapi-spec-validator, it reqognizes an error like that from above but the error (OpenAPIValidationError or iterator) is totally unspecific.
Validating the above yaml with:
try:
spec_dict, spec_url = read_from_filename('model.yaml')
validate_v30_spec(spec_dict)
except IOError as e:
print(e)
except OpenAPIValidationError as e:
print(e)
...gives an output like:
{'description': 'An paged array of pets', 'headers': {'x-next': {'description': 'A link to the next page of responses', 'schema': {'type': 'string'}}}, 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Pets', 'x-scope': ['']}}}} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['responses']['patternProperties']['^[1-5](?:\\d{2}|XX)$']:
{'oneOf': [{'$ref': '#/definitions/Response'},
{'$ref': '#/definitions/Reference'}]}
On instance['paths']['/pets']['get']['responses']['200']:
{'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Pets',
'x-scope': ['']}}},
'description': 'An paged array of pets',
'headers': {'x-next': {'description': 'A link to the next page of '
'responses',
'schema': {'type': 'string'}}}}
No hint on that specific error ("additionalProperty in pet.id" or something like that).
Is openapi-spec-validator not what I'm looking for?
Do I use this validator in a wrong way?
Do I miss anything?
- 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
-
triage/confirmed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
apache/cloudstack#14222 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100