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]: Nullable Enums produce oneOf #4398

Open
4 tasks done
rima1098 opened this issue Sep 11, 2024 · 1 comment
Open
4 tasks done

[Bug]: Nullable Enums produce oneOf #4398

rima1098 opened this issue Sep 11, 2024 · 1 comment
Labels
bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter triaged:core

Comments

@rima1098
Copy link

Describe the bug

When declaring models with Enums that are nullable the generated OpenAPI 3.0 description does produce a oneOf descriminator. (see playground link).

Instead of receiving

enumProp:
    oneOf:
        - $ref: '#/components/schemas/MyEnum'
    nullable: true

i would expect to receive:

enumProp:
    allOf:
        - $ref: '#/components/schemas/MyEnum'
    nullable: true

Reproduction

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

Checklist

@rima1098 rima1098 added the bug Something isn't working label Sep 11, 2024
@timotheeguerin
Copy link
Member

Yeah seems like a bug for other types with $ref is does make an allOf
Playground

@timotheeguerin timotheeguerin added the emitter:openapi3 Issues for @typespec/openapi3 emitter label Sep 12, 2024
@markcowl markcowl added this to the [2024] November milestone Sep 16, 2024
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 triaged:core
Projects
None yet
Development

No branches or pull requests

3 participants