swagger-api / swagger-api/swagger-codegen
Multiple anyOf implementations not supported
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
My model has multiple anyOf implementations, however in any Codegen generator only the 'last' one is created as an interface.
Swagger-codegen version
3.0.14
Swagger declaration file content or url
openapi: 3.0.0
info:
title: Sample Double Interface
version: 0.0.1
paths:
components:
schemas:
PartOne:
properties:
name:
type: string
description: A test description
PartTwo:
properties:
id:
type: string
PartThree:
properties:
otherId:
type: string
PartFour:
properties:
otherIdPart:
type: string
PartMaster:
properties:
origin:
anyOf:
- $ref: '#/components/schemas/PartThree'
- $ref: '#/components/schemas/PartFour'
otherOrigin:
anyOf:
- $ref: '#/components/schemas/PartThree'
- $ref: '#/components/schemas/PartFour'
Command line used for generation
swagger-codegen generate -c java-generator-opts.json -i model/test.yaml -Dmodels --template-engine handlebars -l java
Suggest a fix/enhancement
I think whatever is building the map is using the same key
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 with model/test.yaml and java-generator-opts.json, then run the reported swagger-codegen generate command for the Java generator. Compare the generated representations of origin and otherOrigin, checking whether both anyOf implementations are retained rather than only the last one. Done means both properties generate the expected interfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100