feat(types): ByteStrategy::Base64UrlUnpadded for RFC 7515 alphabets#21
Open
lightsofapollo wants to merge 2 commits into
Open
feat(types): ByteStrategy::Base64UrlUnpadded for RFC 7515 alphabets#21lightsofapollo wants to merge 2 commits into
lightsofapollo wants to merge 2 commits into
Conversation
Adds a third `[generator.types] byte` variant that swaps the inlined `base64_serde` helper's engine from `STANDARD` to `URL_SAFE_NO_PAD`. Per-field `#[serde(with = "base64_serde")]` attributes are unchanged — the alphabet is picked once at codec-emit time from the config. Driven by gpu-cli portal-schema work (JWK thumbprints, DPoP, sealing pubkeys) where the standard padded alphabet doesn't round-trip JOSE fields. Spec-global, not per-field; specs that mix alphabets remain a follow-up. Closes beads openapi-generator-76h. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[generator.types] bytevariant,base64_url_unpadded, that swaps the inlinedbase64_serdehelper's engine fromSTANDARDtoURL_SAFE_NO_PAD(RFC 7515 §2). Per-field#[serde(with = \"base64_serde\")]attributes are unchanged — the alphabet is picked once at codec-emit time from the config, so the variant is opaque to call sites.format: bytehad to be specced as plainstringwith the alphabet documented in field descriptions.serde_withpath discriminator).What changed
src/type_mapping.rsByteStrategy::Base64UrlUnpaddedvariant;map_byteroutes both Base64 variants through the samebase64_serdecodec name +TypeFeature::Base64.src/generator.rsself.config.types.byteand substitutes the engine identifier inside the inlined codec; singleENGINEbinding replaces three literalSTANDARDreferences.src/lib.rsByteStrategyso external consumers can build custom configs.tests/typed_scalars_test.rsbyte_url_unpadded_emits_url_safe_no_pad_engine(new variant emitsURL_SAFE_NO_PAD, noSTANDARD) andbyte_default_emits_standard_engine(locks the historical default).src/type_mapping.rs(tests)base64_url_unpadded.Consumer usage
All
format: bytefields in the spec then round-trip via URL-safe unpadded base64.Test plan
cargo build --libcleancargo test— 51 binaries, 257 passed, 0 failed, 6 ignoredcargo clippy --libclean (pre-existing-D warningsfailures intests/oneof_untagged_tests.rsare unrelated)base64_url_unpaddedround-trips through serdeBase64path still emitsSTANDARD(no regression)byte = \"base64_url_unpadded\"and confirmcargo checkon the generated crateCloses beads issue `openapi-generator-76h`.
🤖 Generated with Claude Code