swagger-typescript-api
swagger-typescript-api copied to clipboard
Any way to keep interface property in the same order
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.
Hi @RoXuS
Do you use swagger-typescript-api via NodeJS generateApi()
?
yes, we have a script inside our monorepo.
I think it happens because of prettier
use alphabetical order, you can override some prettier rules
oh ok! Do you have an idea of what rules I can override?
@RoXuS I have the same problem, currently I don't know why this happened :)
But I will try to fix that
ohhh sorry misunderstanding, ok thx for your job!!
@RoXuS Do you use tslint
or eslint
?
If tslint
try to disable this rule object-literal-sort-keys
If eslint
try to disable this rule https://eslint.org/docs/rules/sort-keys#require-object-keys-to-be-sorted-sort-keys
hum we use eslint but not on our "generated" folder?
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.