swagger-api / swagger-api/swagger-codegen

[Python] external schemas each containing '#/parameter'

Open
#10,954 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I am combining several OpenAPI specifications, each of which has several external references. The generator reaches
all external references but mixes up one #/parameters in an external schema with one in a different external schema.

Swagger-codegen version

3.0.25

Swagger declaration file content or url

OpenApi 3 spec is a mashup of several, but the only two needed to reproduce the problem are:

I will upload the combined spec once this issue is created, but see also https://github.com/NLM-OCCS/python-alma-sdk

Command line used for generation
java -jar lib/swagger-codegen-cli.jar generate -l python -c api-config.json -i target/spec.json --resolve-fully -o target

api-config.json has these contents:

{
  "packageName": "alma_api",
  "modelPackage": "models",
  "apiPackage": "apis"
}
Steps to reproduce
  1. Create an environment with apache ant in the path
  2. Clone from https://github.com/NLM-OCCS/python-alma-sdk
  3. Bootstrap apache ivy by entering "ant bootstrap"
  4. Build the spec and package by entering "ant build"

In the generated code, you can easily see the problem as follows:

grep Almawsv1confjobsjobIdParameter target/alma_api/models/*.py

For instance, the following should each be referencing Almawsv1usersParameter:

target/alma_api/models/user_role.py:        'parameter': 'list[Almawsv1confjobsjobIdParameter]'
target/alma_api/models/user_role.py:        :rtype: list[Almawsv1confjobsjobIdParameter]
target/alma_api/models/user_role.py:        :type: list[Almawsv1confjobsjobIdParameter]
Related issues/PRs

There is an salesforce issue reported to the vendor Ex Libris that I will separately update, and close.

Suggest a fix/enhancement

Unsure of the fix.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone NLM-OCCS/python-alma-sdk, bootstrap Ivy with ant bootstrap, then run ant build using the linked OpenAPI specifications and api-config.json. Inspect target/alma_api/models/user_role.py and the grep result for Almawsv1confjobsjobIdParameter; done means references from the users schema resolve to Almawsv1usersParameter rather than the conf schema parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.