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

Skip duplicate enum values #674

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

czechboy0
Copy link
Collaborator

@czechboy0 czechboy0 commented Nov 16, 2024

Motivation

Some OpenAPI docs, usually through imperfect conversion from another representation, end up with duplicate raw values in enum schemas.

The OpenAPI specification (by referencing the JSON Schema specification) says:

The value of this keyword MUST be an array.  This array SHOULD have at least one element.  Elements in the array SHOULD be unique.

So elements should be unique, but don't have to be. Today the generator fails to generate documents with such duplicate values.

Modifications

Gracefully handle duplicate values by emitting a warning diagnostic and skipping it.

Result

This unblocks generating OpenAPI documents with duplicate enum values, such as the Bluesky OpenAPI doc.

Test Plan

Added a unit test for duplicates.

@theoriginalbit
Copy link
Contributor

I don't believe this applies to enums outside of the schema definitions, should it?

E.g. omit and raise a warning for duplicates for server enum definitions. I don't remember explicitly testing duplicates when I made the recent changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants