Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with items: $ref: for array model. #4

Closed
gilsdav opened this issue Mar 26, 2019 · 3 comments
Closed

Problem with items: $ref: for array model. #4

gilsdav opened this issue Mar 26, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@gilsdav
Copy link

gilsdav commented Mar 26, 2019

Source

https://gist.githubusercontent.com/kinlane/43934f44fd591a6ee59a45267d9e3066/raw/47f6d7115dd17749c408c55861638ffc22d995f4/sample-openapi-30.yaml

Expected

pets.ts :

/* tslint:disable */
import { Pet } from './pet';
export type Pets = Pet[];

Got

pets.ts :

/* tslint:disable */
import { Pet } from './pet';
export type Pets = ; <--- missing value
@luisfpg luisfpg added the bug Something isn't working label Mar 27, 2019
@gilsdav
Copy link
Author

gilsdav commented Apr 5, 2019

@luisfpg As you can see in https://www.w3schools.com/js/js_arrays.asp Array is deprecated, can you use export type Pets = Pet[]; instead of export type Pets = Array<Pet>; ?
Thank you

@luisfpg
Copy link
Contributor

luisfpg commented Apr 5, 2019

@gilsdav Why? Actually, that page says to avoid the Array constructor.
But as a TypeScript type definition, Array<string> and string[] are the same.
Quoted from https://www.typescriptlang.org/docs/handbook/basic-types.html:

TypeScript, like JavaScript, allows you to work with arrays of values. Array types can be written in one of two ways. In the first, you use the type of the elements followed by [] to denote an array of that element type:
let list: number[] = [1, 2, 3];
The second way uses a generic array type, Array:
let list: Array<number> = [1, 2, 3];

Note that neither use new Array.

@gilsdav
Copy link
Author

gilsdav commented Apr 5, 2019

@luisfpg You are right but I think it can be confusing because this javascript type exist just like String. But in that case String is deferent than string.
This is why I never use Array.
What do you think about ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants