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

fix: [openapi31] Fixes #146 when anyOf is used in schemas. #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinxcontrib/openapi/openapi31.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _get_type_from_schema(schema):
dtype = schema["type"]
else:
dtype = set()
for t in schema["anyOf"]:
for t in schema.get("anyOf", []):
if "format" in t.keys():
dtype.add(t["format"])
else:
Expand Down
68 changes: 68 additions & 0 deletions tests/testspecs/v3.1/issue-147.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
openapi: "3.1.0"
info:
title: "Reproducer for issue #147"
components:
schemas:
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
title: Detail
type: array
title: HTTPValidationError
type: object
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
title: Location
type: array
msg:
title: Message
type: string
type:
title: Error Type
type: string
required:
- loc
- msg
- type
title: ValidationError
type: object
paths:
/TimeStampTokens/:
get:
operationId: read_tsts_TimeStampTokens__get
parameters:
- in: query
name: skip
required: false
schema:
default: 0
title: Skip
type: integer
- in: query
name: limit
required: false
schema:
default: 100
title: Limit
type: integer
responses:
'200':
content:
application/json:
schema: {}
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Read Tsts