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

feat: support custom codec files in host repositories #870

Merged
merged 10 commits into from
Aug 8, 2024
Merged

Conversation

ad-world
Copy link
Contributor

@ad-world ad-world commented Aug 8, 2024

DX-658

This ticket adds support for types packages to define schemas for their own custom codecs (that are defined with t.Type or other un-supported primitives).

To make use of this feature in the types package, first create a file titled openapi-gen.config.js. Then, add the following to the package.json in the package "customCodecFile": "openapi-gen.config.js". Then, you can populate the file with your schemas like this:

module.exports = E => {
    return { 
         CustomSchema: () => E.right({ type: 'string' })
    }
}

@ad-world ad-world self-assigned this Aug 8, 2024
@ad-world ad-world marked this pull request as ready for review August 8, 2024 17:30
@ad-world ad-world requested review from a team as code owners August 8, 2024 17:30
this.knownImports[packageName] = {
...this.knownImports[packageName],
...customCodecs,
};
Copy link
Contributor Author

@ad-world ad-world Aug 8, 2024

Choose a reason for hiding this comment

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

question for reviewers: do you think the order should be switched around here? i.e. ...customCodecs comes first, so that if a downstream repo wants to redefine a schema for whatever reason, they can still do that rather than having it overwritten by the main schema definition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

went ahead and made the change, let me know if you think it should be reverted. I think it makes sense to give the end user more priority.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this approach 👍🏽

vmccarty
vmccarty previously approved these changes Aug 8, 2024
Copy link
Contributor

@anshchaturvedi anshchaturvedi left a comment

Choose a reason for hiding this comment

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

🚀

@ad-world ad-world merged commit 5210a57 into master Aug 8, 2024
6 checks passed
@ad-world ad-world deleted the DX-658 branch August 8, 2024 20:23
Copy link

github-actions bot commented Aug 8, 2024

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version @api-ts/[email protected] 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants