-
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
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
packages/cli/generation/ir-generator/src/generateIntermediateRepresentation.ts
Outdated
Show resolved
Hide resolved
@@ -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
…i/inline-types-phase1
This reverts commit c706f87.
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.
Looks good to me - only a couple comments worth considering before merging!
AliasSchema: | ||
### Aliases #### | ||
|
||
AliasSchema: | ||
extends: BaseTypeDeclarationSchema |
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.
Should WithInline
just be part of BaseTypeDeclarationSchema
? It looks like we omitted it from AliasSchema
which is reasonable, but it's theoretically possible that we generate an alias with a bad name too, and we could just as easily create an in-lined alias type.
That way any TypeDeclaration moving forward will always be able to be in-lined. Curious to hear your thoughts though - I realize this case is less important overall.
function getInline(declarationDepth: number): boolean | undefined { | ||
return declarationDepth > 0 ? true : undefined; | ||
} |
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.
It might be worth leaving a function-level comment on this one - I could see us forgetting the rationale around how we're detecting whether or not a type is in-lined. It looks like this was inspired by this comment?
…i/inline-types-phase1
…edundant inline property from IR shapes
…i/inline-types-phase1
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 type declaration.
Changes Made
inline
true on declarationsinline
to the generated Fern definitioninline
to typesTesting
Added more test definitions + evaluate existing test definition snapshots.