Skip to content

Commit

Permalink
Add preserve_path_order cargo feature docs (juhaku#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaku authored May 8, 2023
1 parent 5d0205c commit fcdcc19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ and the `ipa` is _api_ reversed. Aaand... `ipa` is also an awesome type of beer
- **preserve_order** Preserve order of properties when serializing the schema for a component.
When enabled, the properties are listed in order of fields in the corresponding struct definition.
When disabled, the properties are listed in alphabetical order.
- **preserve_path_order** Preserve order of OpenAPI Paths according to order they have been
introduced to the `#[openapi(paths(...))]` macro attribute. If disabled the paths will be
ordered in alphabetical order.
- **indexmap** Add support for [indexmap](https://crates.io/crates/indexmap). When enabled `IndexMap` will be rendered as a map similar to
`BTreeMap` and `HashMap`.
- **non_strict_integers** Add support for non-standard integer formats `int8`, `int16`, `uint8`, `uint16`, `uint32`, and `uint64`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ crate="$1"
echo "Testing crate: $crate..."

if [[ "$crate" == "utoipa" ]]; then
cargo test -p utoipa --features openapi_extensions,preserve_order
cargo test -p utoipa --features openapi_extensions,preserve_order,preserve_path_order,debug
elif [[ "$crate" == "utoipa-gen" ]]; then
cargo test -p utoipa-gen --features utoipa/actix_extras,chrono,decimal,utoipa/uuid,utoipa/time,time,utoipa/repr

Expand Down
3 changes: 3 additions & 0 deletions utoipa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
//! * **preserve_order** Preserve order of properties when serializing the schema for a component.
//! When enabled, the properties are listed in order of fields in the corresponding struct definition.
//! When disabled, the properties are listed in alphabetical order.
//! * **preserve_path_order** Preserve order of OpenAPI Paths according to order they have been
//! introduced to the `#[openapi(paths(...))]` macro attribute. If disabled the paths will be
//! ordered in alphabetical order.
//! * **indexmap** Add support for [indexmap](https://crates.io/crates/indexmap). When enabled `IndexMap` will be rendered as a map similar to
//! `BTreeMap` and `HashMap`.
//! * **non_strict_integers** Add support for non-standard integer formats `int8`, `int16`, `uint8`, `uint16`, `uint32`, and `uint64`.
Expand Down
7 changes: 2 additions & 5 deletions utoipa/src/openapi/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
//! [paths]: https://spec.openapis.org/oas/latest.html#paths-object
use std::iter;

#[cfg(not(feature = "preserve_path_order"))]
use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};
use serde_json::Value;

Expand All @@ -17,7 +14,7 @@ use super::{
};

#[cfg(not(feature = "preserve_path_order"))]
type PathsMap<K, V> = BTreeMap<K, V>;
type PathsMap<K, V> = std::collections::BTreeMap<K, V>;
#[cfg(feature = "preserve_path_order")]
type PathsMap<K, V> = indexmap::IndexMap<K, V>;

Expand Down Expand Up @@ -190,7 +187,7 @@ impl PathItemBuilder {
}

/// Path item operation type.
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, Debug)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "debug", derive(Debug))]
pub enum PathItemType {
Expand Down

0 comments on commit fcdcc19

Please sign in to comment.