Skip to content

Any way to keep interface property in the same order #151

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

Open
RoXuS opened this issue Feb 12, 2021 · 11 comments
Open

Any way to keep interface property in the same order #151

RoXuS opened this issue Feb 12, 2021 · 11 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed next major release This changes of code will added at next major release (*.0.0)

Comments

@RoXuS
Copy link
Contributor

RoXuS commented Feb 12, 2021

Hey,

We commit the generated API code to follow change through our stories. It's good but the order of each interface change at each generation.

First generation:

interface A {
  b: string;
  c: string;
}

second generation:

interface A {
  c: string;
  b: string;
}

There is a way to keep order? Something like alphabetical order?

Thx.

@js2me
Copy link
Member

js2me commented Feb 12, 2021

Hi @RoXuS
Do you use swagger-typescript-api via NodeJS generateApi() ?

@RoXuS
Copy link
Contributor Author

RoXuS commented Feb 12, 2021

yes, we have a script inside our monorepo.

@js2me
Copy link
Member

js2me commented Feb 12, 2021

I think it happens because of prettier use alphabetical order, you can override some prettier rules
image

@js2me js2me self-assigned this Feb 12, 2021
@js2me js2me added bug Something isn't working next major release This changes of code will added at next major release (*.0.0) labels Feb 12, 2021
@RoXuS
Copy link
Contributor Author

RoXuS commented Feb 12, 2021

oh ok! Do you have an idea of what rules I can override?

@js2me
Copy link
Member

js2me commented Feb 12, 2021

@RoXuS I have the same problem, currently I don't know why this happened :)
But I will try to fix that

@RoXuS
Copy link
Contributor Author

RoXuS commented Feb 12, 2021

ohhh sorry misunderstanding, ok thx for your job!!

@js2me
Copy link
Member

js2me commented Feb 12, 2021

@RoXuS Do you use tslint or eslint ?

@js2me
Copy link
Member

js2me commented Feb 12, 2021

If tslint try to disable this rule object-literal-sort-keys

@js2me
Copy link
Member

js2me commented Feb 12, 2021

@RoXuS
Copy link
Contributor Author

RoXuS commented Feb 13, 2021

hum we use eslint but not on our "generated" folder?

@js2me js2me added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 25, 2021
@bisubus
Copy link

bisubus commented Sep 16, 2021

In my case keys were swapped randomly and this couldn't be linter/prettier issue, it was actually unstable OpenAPI output. The solution was to fetch and sort spec object before feeding it to generateApi. Could be a feature as it's useful.

@RoCat RoCat mentioned this issue Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed next major release This changes of code will added at next major release (*.0.0)
Projects
None yet
Development

No branches or pull requests

3 participants