Skip to content
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

fix(api): nestling generated schemas into a new schemas/ directory #756

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

erunion
Copy link
Member

@erunion erunion commented Oct 12, 2023

🧰 Changes

With the ESM and tsup work we're doing in #754 I discovered that the way we're currently generating schemas.ts might result in an uncompilable file due to the way we're processing OpenAPI component schemas top-down.

Basically what happens is that if you use a $ref component in a schema and that component exists further down in the API definition we'll generate a schemas.ts in the order they were specified resulting in us attempting to use const that has not been created yet:

screen_shot_2023-10-11_at_5 16 20_pm_720

There are a number of ways that we can fix this but @kanadgupta had the great idea to shove these schemas into individual files in a new schemas/ directory. The result is that codegen'd SDKs have n more files now but they'll at least be able to be compiled with tooling like tsup.

@erunion erunion added bug Something isn't working refactor Issues about tackling technical debt area:core Issues related to `core`, which is the package that powers the SDKs at runtime labels Oct 12, 2023
readonly title: "Tag";
readonly "x-readme-ref-name": "Tag";
};
import Category from './schemas/Category';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong because CJS and ESM compilation with ts-morph don't create this schemas/ directory but because we're overhauling the CJS and ESM compilation work with #754 I'm going to leave this breakage alone.

@erunion erunion requested a review from kanadgupta October 12, 2023 23:29
@erunion erunion marked this pull request as ready for review October 12, 2023 23:29
@erunion erunion merged commit ec74118 into main Oct 12, 2023
5 checks passed
@erunion erunion deleted the refactor/schema-generation branch October 12, 2023 23:39
@kanadgupta
Copy link
Member

hell yeah 🫶🏽

@erunion erunion added this to the v7 milestone Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core Issues related to `core`, which is the package that powers the SDKs at runtime bug Something isn't working refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants