Skip to content

Fix unsigned integer known format serialization - #1554

Open
MukundaKatta wants to merge 1 commit into
juhaku:masterfrom
MukundaKatta:codex/fix-unsigned-known-formats
Open

Fix unsigned integer known format serialization#1554
MukundaKatta wants to merge 1 commit into
juhaku:masterfrom
MukundaKatta:codex/fix-unsigned-known-formats

Conversation

@MukundaKatta

Copy link
Copy Markdown

Summary

  • serialize unsigned integer known formats as uint8, uint16, uint32, and uint64
  • update non-strict integer schema snapshots for u32 and u64
  • add regression coverage for unsigned known format serialization

Closes #1527

Verification

  • cargo test -p utoipa test_partial_schema_strict_integers
  • cargo test -p utoipa test_partial_schema_non_strict_integers --features non_strict_integers
  • cargo test -p utoipa serialize_unsigned_integer_known_formats --features non_strict_integers
  • cargo fmt --all --check
  • git diff --check

Comment on lines +2034 to +2049
#[serde(rename = "uint8")]
UInt8,
/// 16 bit unsigned integer.
#[cfg(feature = "non_strict_integers")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "non_strict_integers")))]
#[serde(rename = "uint16")]
UInt16,
/// 32 bit unsigned integer.
#[cfg(feature = "non_strict_integers")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "non_strict_integers")))]
#[serde(rename = "uint32")]
UInt32,
/// 64 bit unsigned integer.
#[cfg(feature = "non_strict_integers")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "non_strict_integers")))]
#[serde(rename = "uint64")]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, I would rather change the rename_all to lowercase if possible.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be possible, because other types require kebab case. It's either one or another :/

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot file: utoipa-gen/tests/snapshots/path_derive__derive_path_with_datetime_format_path_parameter.snap
Snapshot: derive_path_with_datetime_format_path_parameter
Source: utoipa-gen/tests/path_derive.rs:447
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expression: parameters
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   14    14 │     "in": "query",
   15    15 │     "name": "start",
   16    16 │     "required": true,
   17    17 │     "schema": {
   18       │-      "format": "date-time",
         18 │+      "format": "datetime",
   19    19 │       "type": "string"
   20    20 │     }
   21    21 │   }
   22    22 │ ]
────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right. Well this is good to merge. Just needs CHANGELOG.md entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unsigned ints should be lowercase

3 participants