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

[Bug]: Illegal characters in component keys (Swagger) #3889

Closed
4 tasks done
Tracked by #3836
flexwie opened this issue Jul 18, 2024 · 5 comments · Fixed by #5006
Closed
4 tasks done
Tracked by #3836

[Bug]: Illegal characters in component keys (Swagger) #3889

flexwie opened this issue Jul 18, 2024 · 5 comments · Fixed by #5006
Assignees
Labels
bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter needs-area

Comments

@flexwie
Copy link

flexwie commented Jul 18, 2024

Describe the bug

If you define a component with keys that include a character outside of [A-Z a-z 0-9 - . _] the corresponding key in the OpenAPI definition will contain that character even if its not allowed by swagger (paste result here).

Is there some way to remove the characters from the generated key as a workaround?

Reproduction

https://typespec.io/playground?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZb3BlbmFwaTMiOwoKdXNpbmcgVHlwZVNwZWMuSHR0cDsKCgpAc2VydmljZSh7CiAgICB0aXRsZTogIlTEUwp9KQpAcm91dGUoIi8iKQpuYW1lc3BhY2UgRW5kcG9pbnRzIMY3QGdldMYJdGFnKCJsaXN0IinFEW9wIMQOKC4uLkNvbW1vblBhcmFtZXRlcnMpOiBzdHJpbmc7Cn0KCm1vZGVsINAkyGBxdWVyecULJHRha2U%2FOiBpbnQzMjsKfQ%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D

Checklist

@flexwie flexwie added the bug Something isn't working label Jul 18, 2024
@timotheeguerin
Copy link
Member

Hi @flexwie can you show where it says having those are not allowed in swagger? You are talking about the parameter called $take?

I pasted the resulting openapi in editor.swagger.io and there was no issues

@timotheeguerin timotheeguerin added needs-info Mark an issue that needs reply from the author or it will be closed automatically emitter:openapi3 Issues for @typespec/openapi3 emitter and removed needs-area labels Jul 18, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added needs-area and removed needs-info Mark an issue that needs reply from the author or it will be closed automatically labels Jul 20, 2024
@wanlwanl wanlwanl self-assigned this Oct 22, 2024
@wanlwanl
Copy link
Member

OAS3 emitter should follow https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 to validate the characters

@wanlwanl
Copy link
Member

@skywing918

@skywing918
Copy link
Member

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9.-_]+$.

Field Name Examples:

User
User_1
User_Name
user-name
my.org.User

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter needs-area
Projects
None yet
4 participants