This repository was archived by the owner on Dec 25, 2024. It is now read-only.
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
[BUG][python] Reference Error when using schema with optional properties #415
Closed
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request
Description
When transforming the schema that have a additional properties, the created python file will have unresolved references in the TypedDict for the optional properties.
Given the yaml file below, the created multi_properties_schema.py
file will have following definition for the optional properties:
MultiPropertiesSchemaOptionalDictInput = typing.TypedDict(
'MultiPropertiesSchemaOptionalDictInput',
{
"data": typing.Union[
DataTupleInput,
DataTuple
],
"message": str,
},
total=False
)
However, the DataTupleInput
and DataTuple
can not be referenced which lead to an error NameError: name 'DataTupleInput' is not defined
during runtime.
openapi-json-schema-generator version
Version 4.1.2
OpenAPI declaration file content or url
openapi: 3.0.0
components:
examples: {}
headers: {}
parameters: {}
requestBodies: {}
responses: {}
schemas:
MultiPropertiesSchema:
properties:
status:
type: integer
format: int32
data:
items:
$ref: '#/components/schemas/ItemsSchema'
type: array
message:
type: string
type: object
required:
- status
additionalProperties: false
ItemsSchema:
properties:
name:
type: string
additionalProperty:
type: string
secondAdditionalProperty:
type: string
info:
title: the test title
version: '1'
description: 'The test REST API'
contact: {}
paths:
'/example/get':
get:
operationId: GetExample
responses:
'200':
description: Ok