-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow component names to contain underscores #268
Conversation
@@ -21,7 +21,7 @@ export const getSortedSchemas = (spec: OpenAPIV3.Document) => { | |||
Object.keys(spec.components?.schemas || {}).map((name) => [ | |||
name, | |||
JSON.stringify(spec.components!.schemas![name]) | |||
.match(/#\/components\/schemas\/[A-Za-z0-9]+/g) | |||
.match(/#\/components\/schemas\/[A-Za-z0-9_]+/g) |
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.
Maybe this could just be like .+
? or \w+
. or even .startsWith('#/components/schemas/')
? No need to be this specific to begin with
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.
Makes sense to me. I can see if the Open API spec has any guidance on allowed characters.
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 this answers it:
All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
Lol it resorted everything |
…xide.ts into allow-underscore_in_name
Well know I want to know why... |
I don't think this is working right. Every entry in the list has export const getSortedSchemas = (spec: OpenAPIV3.Document) => {
return topologicalSort(
Object.keys(spec.components?.schemas || {}).map((name) => [
name,
JSON.stringify(spec.components!.schemas![name])
.match(/#\/components\/schemas\/[a-zA-Z0-9.\-_]+$/g)
?.map((s) => s.replace("#/components/schemas/", "")),
])
);
}; |
Thanks! |
When handling schema components that were generated from types containing generics, you often get components that have names like
TypeX_for_TypeY
. Currently the name matching regex does not match against the underscore and instead only captures up throughTypeX
.This change allows for the
_
character in type names.I'm unsure where the appropriate place to write a test for this is. I can put one together if pointed in the right direction.