swagger-api / swagger-api/swagger-codegen
[Swift4] Can't get a model with an array of base class working
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
A model property typed as an array of polymorphic models stores the base class struct.
My yaml defines these three models:
- section_base (with section_type as a discriminator)
- images_section (with allOf referencing section_base)
- texts_section (with allOf referencing section_base)
In addition, I have a model named doc that includes an array of section_base.
Getting a response from the server, the parsing works, but only for the base model (section_base struct) and not for the other section types.
Is it supported? Am I doing something wrong?
Swagger-codegen version
2.4.0-SNAPSHOT
Swagger declaration file content or url
...
section_base:
type: object
discriminator: section_type
required:
- section_type
properties:
uid:
type: string
section_type:
type: string
title:
type: string
images_section:
allOf:
- $ref: '#/definitions/section_base'
- type: object
properties:
desc:
type: string
texts_section:
allOf:
- $ref: '#/definitions/section_base'
- type: object
properties:
prefix:
type: string
...
Command line used for generation
-l swift4
Related issues/PRs
#6941
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied YAML and the swift4 generator command. Inspect the generated models for section_base, images_section, texts_section, and doc, then verify whether an array of the base type preserves discriminator-based subtypes and add coverage for the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100