oxidecomputer / oxidecomputer/progenitor
Progenitor overly strict when processing some schema elements
Open
@ahl is already working on this.
Since Sep 15, 2022.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 136
- Avg merge
- 8h 36m
- Merged PRs (30d)
- 14
Description
I understand rust is strict, and so this could be ambiguous:
"code": {
"description": "The HTTP error code.",
"type": "integer",
"format": "uint16",
"maximum": 599.0,
"minimum": 400.0
},
Type is integer, but maximum and minimum are parsed as floats
Progenitor then fails with this message:
thread 'main' panicked at 'not clear what we could usefully do here Schema {
schema_data: SchemaData {
nullable: false,
read_only: false,
write_only: false,
deprecated: false,
external_docs: None,
example: None,
title: None,
description: Some(
"The HTTP error code.",
),
discriminator: None,
default: None,
extensions: {},
},
schema_kind: Any(
AnySchema {
typ: Some(
"integer",
),
pattern: None,
multiple_of: None,
exclusive_minimum: None,
exclusive_maximum: None,
minimum: Some(
400.0,
),
maximum: Some(
599.0,
),
properties: {},
required: [],
additional_properties: None,
min_properties: None,
max_properties: None,
items: None,
min_items: None,
max_items: None,
unique_items: None,
enumeration: [],
format: Some(
"uint16",
),
min_length: None,
max_length: None,
one_of: [],
all_of: [],
any_of: [],
not: None,
},
),
}',
Removing the trailing .0 fixes the problem.
The above schema was generated by the rocket-okapi crate
Perhaps instead in the case where the value is exactly representable as a int type, it is accepted, or we print a warning?
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.
Assessment
This issue has not been assessed yet.