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
Code generation for parsing API response does not generate the code that creates the Python model after the response is completed. This happens when using a $ref to define the response instead of just defining the response body inside the path definition.
OpenAPI Spec File
openapi: 3.0.3info:
title: Exampledescription: | Example API definition.version: 1.0.0security:
- BearerAuth: []paths:
/v2/task/{task_id}:
get:
summary: Get the summary of a task.responses:
'200':
$ref: '#/components/responses/task_summary''400':
$ref: '#/components/responses/bad_request''403':
$ref: '#/components/responses/not_authorized'parameters:
- $ref: '#/components/parameters/task_id'components:
securitySchemes:
BearerAuth:
type: httpscheme: bearerbearerFormat: JWTparameters:
task_id:
name: task_idin: pathdescription: The unique identifier of the task targeted by the request.required: trueschema:
$ref: '#/components/schemas/TaskId'responses:
task_summary:
description: Summary of the task at the time the request was made.content:
application/json:
schema:
$ref: '#/components/schemas/TaskSummary'bad_submit_task_request:
description: | The request is invalid. This may indicate an error when parsing a parameter, or an error when parsing or validating the request body. The response body may contain a JSON array with a list of validation errors.content:
application/json:
schema:
type: objectproperties:
validation_errors:
type: arrayminItems: 1items:
type: stringnot_authorized:
description: | User is not authorized to perform this task. bad_request:
description: | The request is invalid. This may indicate an error when parsing a parameter.schemas:
TaskId:
type: stringminLength: 1maxLength: 256pattern: "^[a-zA-Z0-9][a-zA-Z0-9-]*$"example: '80cf75f2-4700-4006-9203-4376b091ee4e'description: A unique identifier for a task. Must not be an empty string.TaskSummary:
type: "object"description: Summary of existing task, including task status.properties:
task_status:
$ref: '#/components/schemas/TaskStatus'required:
- task_statusTaskStatus:
type: stringenum:
- Created
- PayloadProcessing
- Scheduled
- Completed
- Cancelled
- Faileddescription: | Reports status of the task. Lifecycle of a normal task is Created -> PayloadProcessing -> Scheduled -> Completed. where PayloadProcessing - the task is going trough additional compilation/validation/optimization, Scheduled - the task is in the qpu queue, Completed - the task has been executed.
which is not correct. The additional context shows the expected behavior.
Desktop (please complete the following information):
OS: macOS: 14.4.1
Python Version: 3.12.1
openapi-python-client: 0.21.5 [e.g. 0.1.0]
Additional context
Note if I modify the path:
/v2/task/{task_id}:
get:
summary: Get the summary of a task.responses:
'200':
description: Summary of the task at the time the request was made.content:
application/json:
schema:
$ref: '#/components/schemas/TaskSummary''400':
$ref: '#/components/responses/bad_request''403':
$ref: '#/components/responses/not_authorized'parameters:
- $ref: '#/components/parameters/task_id'
Lovely package BTW!
Describe the bug
Code generation for parsing API response does not generate the code that creates the Python model after the response is completed. This happens when using a
$ref
to define the response instead of just defining the response body inside the path definition.OpenAPI Spec File
the code that gets generated here is:
which is not correct. The additional context shows the expected behavior.
Desktop (please complete the following information):
Additional context
Note if I modify the path:
it generates the correct code:
The text was updated successfully, but these errors were encountered: