Open derolf opened 3 years ago
Hello,
Yes, you can try to open a PR if you want
Working on it already, do you know how to use ts-morph to only get the own props of a node?
BTW. I think that ONLY interface should generate explicit schema objects, all other types should always be inlined.
Otherwise, you get a bunch of weird intermediate explicit schema types in the schema, like this:
Patched__title-string--__:
type: object
properties:
title:
type: string
which stems from Patched<{title: string}>
with
export type Patched<T> = {
[P in keyof T]?: T[P] extends Array<infer U> ? Array<Patched<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<Patched<U>> : Patched<T[P]>;
};
These make it hard to maintain a stable OpenAPI spec and the codegens and users downstream cry. (BTW I have handwritten codegens for openAPI -> TypeScript and openAPI -> Dart)
do you know how to use ts-morph to only get the own props of a node?
Nope sorry, I think you'll need to dig into ts-morph to find the method
I think that ONLY interface should generate explicit schema objects, all other types should always be inlined
IMO interfaces & types (i.e. type Foo = { bar: string }
or interface Foo { bar: string }
) (not only interfaces since not everyone use interfaces) should generate explicit schema objects and mapped types should be always inlined
Otherwise, you get a bunch of weird intermediate explicit schema types in the schema, like this:
should be better with https://github.com/Eywek/typoa/commit/bba5a2445d899cc310bd19a8558bad38f976fdb5
Consider
Currently,
Bar
generates a "flat" representation. However, we should embedFoo
usingallOf
intoBar
.Happy to work on a PR if you agree!