Created by: fantavlik
PR checklist
- [ x ] Read the contribution guidelines.
- [ x ] Ran the shell script under
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.
The petsore.yaml for openapi3 doesn't include oneOf so there are no updates. See example output below.
- [ x ] Filed the PR against the correct branch:
master
,. Default:3.4.x
,4.0.x
master
. - [ x ] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
Description of the PR
- Generate type unions for schemas represented with
oneOf
format
Sample input:
openapi: 3.0.0
info:
description: My API Template
title: Fake Service
version: 0.0.1
servers:
- http://fake.com
paths:
/getme:
get:
tags:
- v1
operationId: getMe
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/MyOneOf'
components:
schemas:
MyOneOf:
oneOf:
- $ref: '#/components/schemas/Foo'
- $ref: '#/components/schemas/Bar'
- $ref: '#/components/schemas/Baz'
Foo:
type: object
properties:
kind:
type: string
fooProp:
type: integer
Bar:
type: object
properties:
kind:
type: string
barProp:
type: string
Baz:
type: object
properties:
kind:
type: string
bazProp:
type: string
Sample output MyOneOf.ts:
// tslint:disable
/**
* Fake Service
* My API Template
*
* OpenAPI spec version: 0.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import {
Bar,
Baz,
Foo,
} from './';
/**
* @type MyOneOf
* @export
*/
export type MyOneOf = Bar | Baz | Foo;