-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Milestone
Description
Generation of the oneOf interface works fine if you only reference it once in the spec. For every time you reference the interface it seems like the code generator adds another 'implements' to the same model class.
If I take the example from the docs and add in an additional path that also references the Foo schema:
/foo:
get:
responses:
'200':
description: oneOf
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
/bar:
get:
responses:
'200':
description: oneOf
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
Then the result of the generation is that the generated DTO implements FooOneOfDTO twice, which results in a compilation error:
For completeness, here is the spec file I was using, which was built upon from the docs (which omitted some of the file for brevity, so I've filled it in myself)
openapi: 3.1.0
info:
title: oneOf marker interface
version: 1.0.0
paths:
/foo:
get:
responses:
'200':
description: oneOf
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
/bar:
get:
responses:
'200':
description: oneOf
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
components:
schemas:
Foo:
type: object
properties:
foo:
$ref: '#/components/schemas/FooOneOf'
Bar:
type: object
properties:
x:
type: string
Baz:
type: object
properties:
y:
type: string
FooOneOf:
oneOf:
- $ref: '#/components/schemas/Baz'
- $ref: '#/components/schemas/Bar'
Metadata
Metadata
Assignees
Labels
No labels