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

Improve support for enums #182658

Closed
Tracked by #180056
jloleysens opened this issue May 6, 2024 · 0 comments · Fixed by #188198 · May be fixed by #182662
Closed
Tracked by #180056

Improve support for enums #182658

jloleysens opened this issue May 6, 2024 · 0 comments · Fixed by #188198 · May be fixed by #182662
Assignees
Labels
Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@jloleysens
Copy link
Contributor

jloleysens commented May 6, 2024

Specific to @kbn/config-schema conversion logic in router-to-openapispec package, given a schema like:

  schema.oneOf([
    schema.literal('available'),
    schema.literal('degraded'),
    schema.literal('unavailable'),
    schema.literal('critical'),
  ]);

Give OAS like:

{
  "enum": [
    "available",
    "degraded",
    "critical"
  ],
  "type": "string"
}

Rather than

                   "anyOf": [
                      {
                        "enum": [
                          "available"
                        ],
                        "type": "string"
                      },
                      {
                        "enum": [
                          "degraded"
                        ],
                        "type": "string"
                      },
                      {
                        "enum": [
                          "unavailable"
                        ],
                        "type": "string"
                      },
                      {
                        "enum": [
                          "critical"
                        ],
                        "type": "string"
                      }
                    ]

Notes

  • This should still produce anyOf structures where needed, this is more a matter of finding a way to handle actual enums as enums
@jloleysens jloleysens added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label May 6, 2024
@jloleysens jloleysens added the Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS label May 6, 2024
@jloleysens jloleysens self-assigned this Jul 12, 2024
jloleysens added a commit that referenced this issue Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
1 participant