Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels