oxidecomputer / oxidecomputer/progenitor
Handle default not present in the list of enum values
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 136
- Avg merge
- 8h 36m
- Merged PRs (30d)
- 14
Description
The GithHub API spec contains the following enum:
{
"make_latest": {
"type": "string",
"description": "Specifies ...",
"enum": [
"true",
"false",
"legacy"
],
"default": true
}
}
This fails to validate (in typify) during validate_default_for_external_enum. In this particular case the default being a bool causes further issues (described below). But even if it were a string, validation would fail to find a variant. Based on the OpenAPI spec it seems like the default value should be included as a variant in the case that it was not previously defined.
The above exact example would continue to fail though due to bool defaults not being handled (only strings and maps are), and it is unclear as to how the it should be handled. The proper fix in this case is to fix the spec file (as the default should be "true" per documentation). It may also then be helpful to add an assertion that this construction is unsupported.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in typify at validate_default_for_external_enum and reproduce the GitHub API example with a default absent from the enum. Check how string and boolean defaults are handled, then add coverage for the intended behavior or the unsupported boolean construction. Done means validation no longer rejects a supported missing default, while the boolean case is explicitly handled or asserted as unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, rust
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100