Skip to content

feat: add OpenAPI schemas for credentials, presentations and JwsAlgorithm - #126

Merged
daniel-mader merged 2 commits into
mainfrom
claude/inspiring-archimedes-echxvg-vc-schemas
Oct 26, 2026
Merged

daniel-mader merged 2 commits into
mainfrom
claude/inspiring-archimedes-echxvg-vc-schemas

Conversation

@daniel-mader

@daniel-mader daniel-mader commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #122.

The utoipa feature described DID documents, keys, the DID configuration, type metadata and status types, but not the credential data model or the algorithm enum. An API returning them had to describe them by hand, as UniCore does in agent_identity/src/connection/openapi.rs and document/openapi.rs. Those copies would drift from the types once UniCore uses this crate's.

New schemas

Under utoipa (and vc for the credential types), written by hand like the existing ones in src/openapi.rs:

Type Schema
Credential VCDM 1.1 §4: @context, type, issuer, issuanceDate, credentialSubject required; id, expirationDate, credentialStatus, credentialSchema, refreshService, termsOfUse, evidence; open
Presentation VCDM 1.1 §4.10: @context, type required; verifiableCredential as compact JWS strings (§6.3.1), holder; open
CredentialV2 VCDM 2.0 §4: @context, type, issuer, credentialSubject required; name/description (any language value), validFrom, validUntil, credentialStatus one or many, credentialSchema; open
PresentationV2 VCDM 2.0 §4.13: verifiableCredential as $refs to EnvelopedVc
EnvelopedVc, EnvelopedVp VCDM 2.0 §4.12.1, §4.13.1: @context, id (a data: URL), type, all required
JwsAlgorithm a string enum of its registered names, from JwsAlgorithm::ALL

The rules these encode:

  • @context: the base URI alone, or an array whose first element is it (prefixItems), as check requires.
  • issuer and holder: a URI, or an object with id.
  • Subjects: one, or a non-empty array.
  • Status entries, schemas and the like: typed objects that require type.
  • Dates: date-time strings.
  • PresentationV2: its ToSchema::schemas names EnvelopedVc, so the $ref resolves.
  • Not expressible: "type includes VerifiableCredential" can't be expressed with utoipa's builders (no contains), so the description says it.

Tests

tests/openapi.rs compiles every schema with its references resolved, alone and together, and checks examples and rejections:

  • VCDM 1.1: Example 1, the credential that the Example 31 JWT's claims map back to, and Example 33's vp claim. Each passes as published and as the types write it back.
  • VCDM 2.0: the VC-JOSE-COSE credential, the payload of its presentation JWT (and that payload re-serialized), the published envelope inside it, and the presentation JWT enveloped as an EnvelopedVp.
  • JwsAlgorithm: every algorithm passes; HS256, none, es256 and the empty string fail.
  • Rejections: each required member missing; a context that isn't, or doesn't begin with, the VCDM 1.1 one; an empty context array; an issuer object without id, or a number; no subject; a status entry without type; a VCDM 2.0 credential with the 1.1 context; a 1.1 presentation carrying a credential object or a non-JWS string; an envelope whose id isn't a data: URL, or without id.

Docs

Checks

All with rustc/clippy 1.99.1:

  • fmt;
  • clippy --all-features --all-targets -D warnings;
  • cargo hack clippy --each-feature -D warnings;
  • docs with -D warnings;
  • cargo test --all-features;
  • the --no-default-features --features did-key,software build;
  • cargo publish --dry-run;
  • cargo semver-checks ("no semver update required": the change only adds trait impls).

Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • OpenAPI schemas now cover supported JWS algorithms and, with the vc feature enabled, VCDM 1.1 and 2.0 credentials and presentations, including enveloped forms.
    • The schemas describe supported fields and value formats, helping API documentation represent these types more completely.
  • Documentation
    • Updated feature and design documentation to list the expanded OpenAPI schema coverage.

Under `utoipa`, `Credential` and `Presentation` (VCDM 1.1),
`CredentialV2`, `PresentationV2`, `EnvelopedVc` and `EnvelopedVp`
(VCDM 2.0, feature `vc`) and `JwsAlgorithm` get hand-written schemas
like the existing ones: one-or-many members as `oneOf`, open objects
where the specification leaves them open, and the specification's
required members as `required`. `@context` must begin with the base
context (`prefixItems`), issuers and holders are a URI or an object
with `id`, a VCDM 1.1 presentation carries compact JWS strings, and an
envelope's `id` is a `data:` URL. `JwsAlgorithm` is the enum of its
registered names.

The schema tests check the VCDM 1.1 and VC-JOSE-COSE examples, and what
the types write, against each schema, and the cases the types refuse.

Closes #122.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PB1rHNJ3YpjogEUJQYccc2
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9f9e16f and b346508.

Files selected for processing: 6
  • README.md
  • docs/DESIGN.md
  • docs/FEATURES.md
  • src/lib.rs
  • src/openapi.rs
  • tests/openapi.rs

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 33ab048 and 9f9e16f.

Files selected for processing: 6
  • README.md
  • docs/DESIGN.md
  • docs/FEATURES.md
  • src/lib.rs
  • src/openapi.rs
  • tests/openapi.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The utoipa feature adds OpenAPI schemas for JwsAlgorithm and VCDM 1.1 and 2.0 credential and presentation types, including envelopes. Documentation and tests cover the schemas, examples, and invalid values.

Changes: OpenAPI schema support

Layer / File(s) Summary
Schema foundations and algorithm enum
src/openapi.rs
Adds a JwsAlgorithm string-enum schema and shared helpers for VC schema fields.
Credential, presentation, and envelope schemas
src/openapi.rs, README.md, docs/DESIGN.md, docs/FEATURES.md, src/lib.rs
Adds schemas for VCDM 1.1 and 2.0 credentials and presentations, plus enveloped credentials and presentations. Updates feature documentation to list the schema coverage.
Schema registration and validation
tests/openapi.rs
Registers the schemas and tests their component references, valid examples, serialized values, and rejection cases.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature · Severity of issue fixed: Medium

Possibly related issues

  • impierce/ssi-agent#439 — This PR adds the JwsAlgorithm schema that the issue identifies as a replacement for a hand-written algorithm mapping.

Possibly related PRs

  • impierce/identity-kit#100 — This PR extends the schema collection and isolated-compilation test infrastructure established by PR #100.

Suggested labels: Documentation

Merge Risk: Minimal · previous review 9f9e1

The reviewed schemas have no identified issue that needs resolution before merging. Merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 3 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main changes: adding OpenAPI schemas for credentials, presentations, and JwsAlgorithm.
Linked Issues check Passed Issue #122 requires ToSchema support for Credential, Presentation, CredentialV2, EnvelopedVc, and JwsAlgorithm, plus schema tests and a FEATURES.md update. The supplied change summary re…
Out of Scope Changes check Passed The changes remain connected to issue #122. PresentationV2 and EnvelopedVp extend the same VCDM 2.0 presentation and envelope schema model. Their schemas, references, tests, and documentation supp…
Full details: Linked Issues check

Explanation

Issue #122 requires ToSchema support for Credential, Presentation, CredentialV2, EnvelopedVc, and JwsAlgorithm, plus schema tests and a FEATURES.md update. The supplied change summary reports all required schemas under the requested feature gates, required members and value-shape rules, resolved-reference tests, VCDM 1.1 and 2.0 example tests, rejection tests, and the FEATURES.md row. src/openapi.rs confirms the JwsAlgorithm enum schema uses JwsAlgorithm::ALL.

Full details: Out of Scope Changes check

Explanation

The changes remain connected to issue #122. PresentationV2 and EnvelopedVp extend the same VCDM 2.0 presentation and envelope schema model. Their schemas, references, tests, and documentation support the requested credential and presentation OpenAPI coverage. The supplied change summary shows no unrelated product behavior or unrelated files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 3 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@daniel-mader
daniel-mader merged commit ef55ca2 into main Oct 26, 2026
32 checks passed
@daniel-mader
daniel-mader deleted the claude/inspiring-archimedes-echxvg-vc-schemas branch October 26, 2026 22:29
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.

OpenAPI schemas for Credential, Presentation, CredentialV2 and JwsAlgorithm

2 participants