Skip to content
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] Routes generated with Headers and no content results in TypeErrors #105

Closed
@spacether

Description

@spacether

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 (example)
Description

When generating a client from a spec that includes responses with no content and headers the generated code has type errors and cannot be used. Attempting to import an api results in the following output.

>>> from openapi_client.apis.tags import project_api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lberhane-meskel/WorkRepos/openapi/openapi_client/apis/tags/project_api.py", line 12, in <module>
    from openapi_client.paths.projects.post import CreateProject
  File "/Users/lberhane-meskel/WorkRepos/openapi/openapi_client/paths/projects/post.py", line 109, in <module>
    class ApiResponseFor201(api_client.ApiResponse):
  File "/Users/lberhane-meskel/.pyenv/versions/3.8.7/lib/python3.8/dataclasses.py", line 1019, in dataclass
    return wrap(cls)
  File "/Users/lberhane-meskel/.pyenv/versions/3.8.7/lib/python3.8/dataclasses.py", line 1011, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/Users/lberhane-meskel/.pyenv/versions/3.8.7/lib/python3.8/dataclasses.py", line 925, in _process_class
    _init_fn(flds,
  File "/Users/lberhane-meskel/.pyenv/versions/3.8.7/lib/python3.8/dataclasses.py", line 502, in _init_fn
    raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'headers' follows default argument
openapi-generator version

6.2.1

OpenAPI declaration file content or url

https://gist.github.com/LeulBM/07fc708a6466de98af5fcee0cf47d97a

Generation Details

openapi-generator generate -g python -i spec.yaml

Steps to reproduce
  1. Generate client using above command
  2. Attempt to import the api
    from openapi_client.apis.tags import artifact_api
Suggest a fix

The issue seems to have to do with responses that have headers and no content, such as the 200 response at 98 in the spec file.

Copied from OpenAPITools/openapi-generator#14267
Thank you for filing it @LeulBM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions