Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ export interface {{classname}} { {{>modelGenericAdditionalProperties}}

{{/parent}}
{{^parent}}
{{#oneOf}}
{{#-first}}
{{>modelOneOf}}
{{/-first}}
{{/oneOf}}
{{^oneOf}}
{{>modelGeneric}}
{{/oneOf}}

{{/parent}}
{{/discriminator}}
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,25 @@ public void testTaggedUnionImports() throws Exception {
);
}

@Test
public void testTaggedUnionsOneOfWithoutDiscriminator() throws Exception {
File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("typescript-angular")
.setInputSpec("src/test/resources/3_0/typescript-angular/issue_20859.yaml")
.addAdditionalProperty(TypeScriptAngularClientCodegen.TAGGED_UNIONS, true)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

new DefaultGenerator().opts(configurator.toClientOptInput()).generate();

TestUtils.assertFileContains(
Paths.get(output + "/model/zooInner.ts"),
"export type ZooInner = Cat | Dog;"
);
}

@Test
public void testModelNameMappings() throws Exception {
final String specPath = "src/test/resources/2_0/issue_8289.json";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
openapi: 3.0.0
info:
title: OpenAPI definition
version: v0
paths:
/api/test/zoo:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Zoo'
components:
schemas:
Animal:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
required:
- type
Cat:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
purrFrequency:
type: integer
format: int32
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
barkVolume:
type: integer
format: int32
Zoo:
type: array
items:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
Loading