You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When an input schema has a required const property, the generated code does makes calls to typing.cast, but does not import it, leading to failures when trying to run ruff over the generated code.
OpenAPI Spec File
openapi: 3.1.0
info:
title: Pets Example
version: 1.0.0
paths:
/pets:
post:
requestBody:
description: Create a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Return a 200 status to indicate that the pet was created successfully
components:
schemas:
Pet:
required:
- type
properties:
type:
const: cat
Desktop (please complete the following information):
OS: macOS 14.6.1
Python Version: 3.12.6
openapi-python-client version: latest main (also present in latest release, 0.21.6)
Additional context
Removing type from the required field list in the example above makes the problem disappear - in this case, cast is still used, but is properly imported.
The text was updated successfully, but these errors were encountered:
benweint
added a commit
to benweint/openapi-python-client
that referenced
this issue
Oct 28, 2024
Describe the bug
When an input schema has a required
const
property, the generated code does makes calls totyping.cast
, but does not import it, leading to failures when trying to runruff
over the generated code.OpenAPI Spec File
Desktop (please complete the following information):
main
(also present in latest release, 0.21.6)Additional context
Removing
type
from therequired
field list in the example above makes the problem disappear - in this case,cast
is still used, but is properly imported.The text was updated successfully, but these errors were encountered: