Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python] Generator does not correctly generate examples #19042

Open
5 of 6 tasks
zdevaty opened this issue Jul 1, 2024 · 0 comments
Open
5 of 6 tasks

[BUG] [Python] Generator does not correctly generate examples #19042

zdevaty opened this issue Jul 1, 2024 · 0 comments

Comments

@zdevaty
Copy link

zdevaty commented Jul 1, 2024

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

I want to improve the examples in the documentation of the generated Python client. When I include the example within the schema or not at all, following is generated:

data_experiment = eliona.api_client2.DataExperiment() # DataExperiment

While that's alright, I would like to have the instance initialized with example data as well (in reality that class has a lot of properties).

So I moved the example out of the schema a level up (see the openapi.yaml excerpt below), and following was generated:

data_experiment = {"assetId":4711} # DataExperiment

With that, I gained example data, but it is no longer a DataExperiment class.

Am I missing something, or is there something wrong with the generator?

openapi-generator version

7.3.0, 7.5.0, 7.6.0

OpenAPI declaration file content or url
requestBody:
    required: true
    content:
      application/json:
        schema:
          title: DataExperiment
          type: object
          description: Data for assets
          required:
            - assetId
          properties:
            assetId:
              type: integer
              description: ID of the corresponding asset
              example: 4711
        example:
          assetId: 4711
Generation Details
docker run --rm \
     -v "${PWD}:/local" \
    openapitools/openapi-generator-cli:v7.6.0 \
    generate \
    -g python \
    -o /local \
    ...
Steps to reproduce

Generate the client, see the docs.

Related issues/PRs

None found

Suggest a fix

Don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant