Open TheDechev opened 1 year ago
ping
//base.type.ts
export type BaseType = {
readonly _id?: string;
};
//address.type.ts
export type Address = BaseType & {
addressLine1: string;
addressLine2?: string;
city: string;
countryCode: string;
postalCode?: string;
state?: string;
readonly country?: Country;
}
//country.type.ts
export type Currency = {
code: string;
name: string;
symbol?: string;
}
export type PostalCode = {
format?: string;
regex?: string;
}
export type Country = BaseType & {
currencies: Array<Currency>;
flagImage: string;
isEnabled: boolean;
iso2: string;
iso3: string;
name: string;
officialName?: string;
postalCode: PostalCode;
timezones: Array<string>;
}
gets converted into below files
//base.type.yaml
... removed some parts of yamls here for reducing the size ...
components:
schemas:
BaseType:
properties:
_id:
title: BaseType._id
type: string
additionalProperties: false
title: BaseType
type: object
//address.type.yaml
... removed some parts of yamls here for reducing the size ...
components:
schemas:
Address:
properties:
addressLine1:
title: addressLine1
type: string
addressLine2:
title: addressLine2
type: string
city:
title: city
type: string
countryCode:
title: countryCode
type: string
postalCode:
title: postalCode
type: string
state:
title: state
type: string
country:
title: country
required:
- addressLine1
- city
- countryCode
additionalProperties: false
title: Address
type: object
//country.type.yaml
... removed some parts of yamls here for reducing the size ...
components:
schemas:
Currency:
properties:
code:
title: Currency.code
type: string
name:
title: Currency.name
type: string
symbol:
title: Currency.symbol
type: string
required:
- code
- name
additionalProperties: false
title: Currency
type: object
PostalCode:
properties:
format:
title: PostalCode.format
type: string
regex:
title: PostalCode.regex
type: string
additionalProperties: false
title: PostalCode
type: object
Country:
properties:
currencies:
items:
$ref: '#/components/schemas/Currency'
title: currencies
type: array
flagImage:
title: flagImage
type: string
isEnabled:
title: isEnabled
type: boolean
iso2:
title: iso2
type: string
iso3:
title: iso3
type: string
name:
title: name
type: string
officialName:
title: officialName
type: string
postalCode:
$ref: '#/components/schemas/PostalCode'
title: postalCode
timezones:
items:
type: string
title: timezones
type: array
required:
- currencies
- flagImage
- isEnabled
- iso2
- iso3
- name
- postalCode
- timezones
additionalProperties: false
title: Country
type: object
this is not a valid yaml and doesn't represent the real type schema.
Anyone figure out a solution to this issue?
If it would help for someone here is some tips:
typeconv
to convert this .d.ts
file to what ever you want.
Hey,
When using NodeJS/ES6 to convert existing Typescript interfaces to OpenAPI it ignores nested interfaces that are declared in other files.
For example, the following interface:
Uses the
StatusResponse
that is defined in another file as simply:Yet the final
MyResponse
schema ignores the status field entirely and just shows theid
field.Has anyone encountered this before or can suggest a solultion?
Thanks