-
Notifications
You must be signed in to change notification settings - Fork 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
feat(cli): Add inline
property to type references from properties in Fern definition with OpenAPI importer
#5248
base: main
Are you sure you want to change the base?
Conversation
|
||
BaseTypeDeclarationSchema: | ||
extends: | ||
inline: optional<boolean> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assume this is the only thing that changed? nit: would be nice to remove the formatting changes for this PR
packages/cli/generation/ir-generator/src/generateIntermediateRepresentation.ts
Outdated
Show resolved
Hide resolved
const namedProps = Object.values(types).flatMap((type) => { | ||
if (type.shape.type !== "object") { | ||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if an inline type is "extended" or if a discriminated union references the inline type as a variant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to iterate over every single TypeReference and store the reference. Maybe we make parseTypeReference
stateful?
@@ -283,6 +283,7 @@ types: | |||
type: string | |||
docs: | | |||
A unique name for the property. | |||
inline: optional<boolean> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this property? If a SchemaWithExample contains another SchemaWithExample that is not a reference, you already know the type is inlined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words, in openapi-ir-to-fern when you call buildTypeDeclaration()
and then that calls buildTypeReference
and that calls buildTypeDeclaration
again, you know that the second declaration call is for an inlined type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we just tracked depth of call, then i think we should be able to control inline based on that
Description
In the Fern definition, you can express your desire to inline a type from a property on a type or request:
The IR generated from this Fern definition will store the desire to inline a type on the property and on the type declaration. For the type declaration,
inline
will only be true if all properties reference the type express desire to inline a type.Changes Made
inline
true on properties referencing a typeinline
to the generated Fern definitioninline
to property and to typeTesting
Added more test definitions + evaluate existing test definition snapshots.