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 client generator doesn't handle schema clashes #19612

Open
5 of 6 tasks
brendanator opened this issue Sep 18, 2024 · 0 comments
Open
5 of 6 tasks

[BUG] Python client generator doesn't handle schema clashes #19612

brendanator opened this issue Sep 18, 2024 · 0 comments

Comments

@brendanator
Copy link

brendanator commented Sep 18, 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

The GitHub openapi spec contains a commit object which contains an inner commit object.

When I generate a client using the Python generator only the inner commit object is generated

openapi-generator version
$ docker run --rm openapitools/openapi-generator-cli:latest --version
openapi-generator-cli 7.9.0-SNAPSHOT
  commit : ca378b4
  built  : -999999999-01-01T00:00:00+18:00
  source : https://github.com/openapitools/openapi-generator
  docs   : https://openapi-generator.tech/
OpenAPI declaration file content or url

Here's the full GitHub openapi spec and here's the relevant snippet

      "commit": {
        "title": "Commit",
        "description": "Commit",
        "type": "object",
        "properties": {
          ...
          "commit": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "example": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e"
              },
              "author": {
                "$ref": "#/components/schemas/nullable-git-user"
              },
              "committer": {
                "$ref": "#/components/schemas/nullable-git-user"
              },
              "message": {
                "type": "string",
                "example": "Fix all the bugs"
              },
              "comment_count": {
                "type": "integer",
                "example": 0
              },
              "tree": {
                "type": "object",
                "properties": {
                  "sha": {
                    "type": "string",
                    "example": "827efc6d56897b048c772eb4087f854f46256132"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://api.github.com/repos/octocat/Hello-World/tree/827efc6d56897b048c772eb4087f854f46256132"
                  }
                },
                "required": [
                  "sha",
                  "url"
                ]
              },
              "verification": {
                "$ref": "#/components/schemas/verification"
              }
            },
            "required": [
              "author",
              "committer",
              "comment_count",
              "message",
              "tree",
              "url"
            ]
          },
          ...
Generation Details
docker run --rm -v /tmp:/local openapitools/openapi-generator-cli:latest generate \
  --input-spec https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.2022-11-28.json \
  --generator-name python \
  --output /local
Steps to reproduce
  1. Run the docker generation command above
  2. cat /tmp/openapi_client/models/commit.py
  3. See that it is the inner commit object and the outer one does not exist
Suggest a fix

I suggest including the outer name in the name of nested objects - in this case the inner class would be named CommitCommit

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