-
-
Notifications
You must be signed in to change notification settings - Fork 739
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
chore: automate openapi schema list #6463
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
constraintSchemaBase, | ||
unknownFeatureEvaluationResult, | ||
playgroundStrategyEvaluation, | ||
strategyEvaluationResults, |
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.
These are not schemas, but they are exported inside schema files. I don't think it's a problem but at least it posts a question on whether they should be there or not.
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.
Good catch. I think I'm responsible for all of these, actually 😅 I think some of them make sense to keep where they are, but others maybe not. I don't think unknownFeatureEvaluationResult
is actually used anywhere 🤔
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.
No need to fix them right now, and we can continue growing this list if needed, but at least it will pop the question. Personally, I moved the ones I introduced https://github.com/Unleash/unleash/pull/6463/files#r1516086818 but it would have been fine to add them to this exception list.
@@ -61,4 +61,4 @@ export const clientMetricsEnvSchema = { | |||
}, | |||
} as const; | |||
|
|||
export type ClientMetricsSchema = FromSchema<typeof clientMetricsEnvSchema>; | |||
export type ClientMetricsEnvSchema = FromSchema<typeof clientMetricsEnvSchema>; |
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.
This one was a bad copy paste that was spotted thanks to automating the exports
export const TAG_MIN_LENGTH = 2; | ||
export const TAG_MAX_LENGTH = 50; |
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.
These two were moved instead of excluding them from the schemas
@@ -2,3 +2,10 @@ | |||
. "$(dirname -- "$0")/_/husky.sh" | |||
|
|||
npx lint-staged | |||
|
|||
node .husky/update-openapi-spec-list.js |
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.
Using node instead of bash, because it should be available in local dev
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.
This looks good to me! 😄 While I'm generally not a big fan of pre-commit hooks, I think automating this is great. Is there a way to do it that's less invasive?
constraintSchemaBase, | ||
unknownFeatureEvaluationResult, | ||
playgroundStrategyEvaluation, | ||
strategyEvaluationResults, |
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.
Good catch. I think I'm responsible for all of these, actually 😅 I think some of them make sense to keep where they are, but others maybe not. I don't think unknownFeatureEvaluationResult
is actually used anywhere 🤔
.husky/update-openapi-spec-list.js
Outdated
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.
Does this always write the file? How long does it take?
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'm generally not a big fan of pre-commit hooks
That makes 2 of us, but this is a quick way to find out whether this is a good solution or not. There are other alternatives, some less invasive, but this will help us understand what are our needs.
Does this always write the file?
Yes, only on commit, but it checks if the file was modified, and only then includes it in the change.
How long does it take?
Around 30ms
About the changes
This PR automates the generation of exported open api schemas on pre-commit, removing some manual steps and also standardizing the process. The schema list definition now looks way simpler:
unleash/src/lib/openapi/index.ts
Lines 37 to 49 in b6f3877
Also added
unleash/src/lib/openapi/spec/index.ts
Lines 1 to 4 in 2817e66