forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Typescript] Generate oneOf schemas as type unions (OpenAPITools#19494)
* Add oneOf model for Typescript generator * Update import procces: For oneOfs only import $refs within the oneOf * Remove new line after description * Update samples * Typescript: Update model.mustache * Typescript: Remove emun from oneOf models * Update samples * Typescript oneOf: add discriminator and update deserialize procces * Typescript: update tests * Typescript oneOf: move type mapping to models * Typescript: Update samples * Typescript: Update type of mappig * Typescript: Update type of mappig * Typescript oneOf: update deserializing logic * Typescript: Update samples * Revert "[typescript] fix: `enum` can not receive stringified class name (OpenAPITools#19481)" This reverts commit 4238f17. * [typescript] chore: update fixtures --------- Co-authored-by: ksvirkou-hubspot <[email protected]>
- Loading branch information
1 parent
1518237
commit 7510e6b
Showing
91 changed files
with
231 additions
and
1,723 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{#hasImports}} | ||
import { | ||
{{#imports}} | ||
{{{.}}}{{importFileExtension}}, | ||
{{/imports}} | ||
} from './'; | ||
|
||
{{/hasImports}} | ||
/** | ||
* @type {{classname}} | ||
* Type | ||
* @export | ||
*/ | ||
export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}; | ||
|
||
/** | ||
* @type {{classname}}Class{{#description}} | ||
* {{{.}}}{{/description}} | ||
* @export | ||
*/ | ||
export class {{classname}}Class { | ||
{{#discriminator}} | ||
static readonly discriminator: string | undefined = "{{discriminatorName}}"; | ||
{{/discriminator}} | ||
{{^discriminator}} | ||
static readonly discriminator: string | undefined = undefined; | ||
{{/discriminator}} | ||
{{#hasDiscriminatorWithNonEmptyMapping}} | ||
|
||
static readonly mapping: {[index: string]: string} | undefined = { | ||
{{#discriminator.mappedModels}} | ||
"{{mappingName}}": "{{modelName}}", | ||
{{/discriminator.mappedModels}} | ||
}; | ||
{{/hasDiscriminatorWithNonEmptyMapping}} | ||
{{^hasDiscriminatorWithNonEmptyMapping}} | ||
|
||
static readonly mapping: {[index: string]: string} | undefined = undefined; | ||
{{/hasDiscriminatorWithNonEmptyMapping}} | ||
} |
77 changes: 0 additions & 77 deletions
77
modules/openapi-generator/src/test/resources/3_0/enum_mapping_test.yaml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.