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

Allow component names to contain underscores #268

Merged
merged 8 commits into from
Sep 9, 2024
Merged
2 changes: 1 addition & 1 deletion oxide-openapi-gen-ts/src/client/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

@david-crespo david-crespo Sep 9, 2024

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

@augustuswm augustuswm Sep 9, 2024

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\.\-_]+$.

?.map((s) => s.replace("#/components/schemas/", "")),
])
);
Expand Down
Loading