type definitions should occur in a stable order (rustfmt)
This commit is contained in:
parent
abf423f96c
commit
aab5061b56
26
src/main.rs
26
src/main.rs
|
@ -974,17 +974,21 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
|
||||||
* a stable order within the file, so we first collect a list of type IDs
|
* a stable order within the file, so we first collect a list of type IDs
|
||||||
* that we can sort by their visible name.
|
* that we can sort by their visible name.
|
||||||
*/
|
*/
|
||||||
let mut ids = ts.id_to_entry.values().filter_map(|te| match &te.details {
|
let mut ids = ts
|
||||||
TypeDetails::Object(_)
|
.id_to_entry
|
||||||
| TypeDetails::NewType(_)
|
.values()
|
||||||
| TypeDetails::Enumeration(_) => {
|
.filter_map(|te| match &te.details {
|
||||||
Some((te.name.as_deref().unwrap(), &te.id))
|
TypeDetails::Object(_)
|
||||||
}
|
| TypeDetails::NewType(_)
|
||||||
TypeDetails::Basic
|
| TypeDetails::Enumeration(_) => {
|
||||||
| TypeDetails::Unknown
|
Some((te.name.as_deref().unwrap(), &te.id))
|
||||||
| TypeDetails::Array(_)
|
}
|
||||||
| TypeDetails::Optional(_) => None,
|
TypeDetails::Basic
|
||||||
}).collect::<Vec<_>>();
|
| TypeDetails::Unknown
|
||||||
|
| TypeDetails::Array(_)
|
||||||
|
| TypeDetails::Optional(_) => None,
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
ids.sort_by(|a, b| a.0.cmp(&b.0));
|
ids.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
|
||||||
a("pub mod types {");
|
a("pub mod types {");
|
||||||
|
|
Loading…
Reference in New Issue