swagger-api / swagger-api/swagger-codegen

[python client] can't access fields that reference definition

Open
#1,088 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Python Issue: Workaround available
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

My response contains an enum field (netAccessType in the example below). In the spec, the field is defined via "ref" for reuse purpose. This field is mapped to an empty list in the python object generated by the client instead of a string.

It appears this issue is not enum specific -- other types referenced are also empty.

Here's an example of spec:

...
accessType:
  type: string
  description: access type 
  enum:
    - public
    - private

...

NetworkConfig:
  properties:
    netAccessType:
      $ref : '#/definitions/accessType'
    ...

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

Start by reproducing Python client generation with the issue's NetworkConfig and accessType specification, then trace how referenced properties are handled. Done means referenced fields, including the enum example, are represented with their expected values instead of empty lists.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.