diff --git a/Cargo.lock b/Cargo.lock index da9b6933..9a7105df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8149,9 +8149,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utoipa" -version = "5.0.0-beta.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fac56d240b49c629b9083c932ac20a23d926937e67c21ba209f836e2983d4f" +checksum = "514a48569e4e21c86d0b84b5612b5e73c0b2cf09db63260134ba426d4e8ea714" dependencies = [ "indexmap 2.5.0", "serde", @@ -8162,9 +8162,9 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "5.0.0-beta.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d88270777931b8133b119c953062bd41665bb8507841f7d433f46d2765e9d4" +checksum = "5629efe65599d0ccd5d493688cbf6e03aa7c1da07fe59ff97cf5977ed0637f66" dependencies = [ "proc-macro2", "quote", @@ -8174,9 +8174,9 @@ dependencies = [ [[package]] name = "utoipa-scalar" -version = "0.2.0-beta.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc86065a210b8540e46d15e0844765d1d14eec7fd6221c2b0de8f6edde990648" +checksum = "c1291aa7a2223c2f8399d1c6627ca0ba57ca0d7ecac762a2094a9dfd6376445a" dependencies = [ "axum 0.7.5", "serde", diff --git a/agent_api_rest/Cargo.toml b/agent_api_rest/Cargo.toml index 987c83ea..193e3f3e 100644 --- a/agent_api_rest/Cargo.toml +++ b/agent_api_rest/Cargo.toml @@ -31,8 +31,8 @@ tower-http.workspace = true tracing.workspace = true url.workspace = true uuid.workspace = true -utoipa = { version = "=5.0.0-beta.0", features = ["axum_extras", "yaml"] } -utoipa-scalar = { version = "=0.2.0-beta.0", features = ["axum"] } +utoipa = { version = "5.2", features = ["axum_extras", "yaml"] } +utoipa-scalar = { version = "0.2", features = ["axum"] } # TODO: wait for new release that contains PR juhaku/utoipa#1002 (current version `=5.0.0-alpha.1`) # utoipa = { git = "https://github.com/juhaku/utoipa.git", rev = "f2a7143", features = [ # "axum_extras", @@ -44,11 +44,15 @@ utoipa-scalar = { version = "=0.2.0-beta.0", features = ["axum"] } # ] } [dev-dependencies] -agent_event_publisher_http = { path = "../agent_event_publisher_http", features = ["test_utils"] } +agent_event_publisher_http = { path = "../agent_event_publisher_http", features = [ + "test_utils", +] } agent_holder = { path = "../agent_holder", features = ["test_utils"] } agent_identity = { path = "../agent_identity", features = ["test_utils"] } agent_issuance = { path = "../agent_issuance", features = ["test_utils"] } -agent_secret_manager = { path = "../agent_secret_manager", features = ["test_utils"] } +agent_secret_manager = { path = "../agent_secret_manager", features = [ + "test_utils", +] } agent_shared = { path = "../agent_shared", features = ["test_utils"] } agent_store = { path = "../agent_store" } agent_verification = { path = "../agent_verification", features = [ diff --git a/agent_api_rest/README.md b/agent_api_rest/README.md index d70cdadc..3952caf3 100644 --- a/agent_api_rest/README.md +++ b/agent_api_rest/README.md @@ -12,6 +12,10 @@ The current version of the REST API is `v0`. > [!NOTE] > UniCore uses [Scalar](https://scalar.com) to make its OpenAPI specification interactive. It is served under `///api-reference` (for example: `/v0/api-reference`). The `openapi.yaml` file can be downloaded there as well. The latest version of the `openapi.yaml` file is also deployed as part of the documentation at https://docs.impierce.com/unicore/api-reference. +#### Generate OpenAPI specification + +The `openapi.yaml` file can be generated manually by executing the test `generate_openapi_file()` _(ignored in a regular test run)_. + #### Swagger UI You can also run a local Swagger UI container to inspect the OpenAPI specification. diff --git a/agent_api_rest/openapi.yaml b/agent_api_rest/openapi.yaml index 1a66112c..166dd8fb 100644 --- a/agent_api_rest/openapi.yaml +++ b/agent_api_rest/openapi.yaml @@ -140,9 +140,8 @@ paths: description: Standard OAuth 2.0 endpoint that returns an access_token after successful authorization. operationId: token requestBody: - description: '' content: - application/x-www-form-urlencoded: + application/json: schema: $ref: '#/components/schemas/TokenRequest' required: true @@ -182,7 +181,7 @@ paths: Standard OpenID4VCI endpoint that allows the Issuer to pass information about the credential offer to the Holder's wallet. [Specification](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-offer-endpoint) - operationId: offers + operationId: offers_params requestBody: content: application/json: @@ -200,9 +199,8 @@ paths: description: Standard OAuth 2.0 endpoint. operationId: redirect requestBody: - description: '' content: - application/x-www-form-urlencoded: + application/json: schema: $ref: '#/components/schemas/GenericAuthorizationResponse' required: true @@ -252,7 +250,7 @@ paths: - Verification summary: Get an Authorization Request description: Retrieve an existing Authorization Request. - operationId: get_authorization_requests + operationId: all_authorization_requests parameters: - name: id in: path @@ -328,7 +326,7 @@ paths: - Issuance summary: Retrieve a credential description: Retrieves an existing credential by its ID. - operationId: get_credentials + operationId: credential parameters: - name: id in: path @@ -432,7 +430,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SendOfferEndpointRequest' + $ref: '#/components/schemas/SendOfferEndpointRequestSchema' example: offerId: '0001' targetUrl: https://wallet.example.com/openid4vci/offers @@ -445,20 +443,71 @@ paths: components: schemas: AuthorizationRequestsEndpointRequest: - allOf: - - allOf: - - type: 'null' - - $ref: '#/components/schemas/PresentationDefinitionResource' - - type: object - required: - - nonce - properties: - nonce: - type: string - state: - type: - - string - - 'null' + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + AuthorizationServerMetadata: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + CredentialIssuerMetadata: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + CredentialRequest: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + CredentialResponse: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + CredentialView: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string CredentialsEndpointRequest: type: object required: @@ -473,6 +522,28 @@ components: type: boolean offerId: type: string + GenericAuthorizationRequest: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string + GenericAuthorizationResponse: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: + type: string OffersEndpointRequest: type: object required: @@ -481,19 +552,37 @@ components: offerId: type: string Oid4vciOfferEndpointRequest: - allOf: - - $ref: '#/components/schemas/CredentialOffer' - - type: object - SendOfferEndpointRequest: type: object required: - - offerId - - targetUrl + - foo + - bar properties: - offerId: + bar: + type: integer + format: int32 + foo: + type: string + SendOfferEndpointRequestSchema: + type: object + required: + - offer_id + - target_url + properties: + offer_id: + type: string + target_url: + type: string + TokenRequest: + type: object + required: + - foo + - bar + properties: + bar: + type: integer + format: int32 + foo: type: string - targetUrl: - $ref: '#/components/schemas/Url' tags: - name: (public) description: A collection of endpoints that should be publicly accessible without authentication. They are used to resolve metadata or allow communication with wallets. diff --git a/agent_api_rest/src/holder/openid4vci/mod.rs b/agent_api_rest/src/holder/openid4vci/mod.rs index ec0644e5..f51a0104 100644 --- a/agent_api_rest/src/holder/openid4vci/mod.rs +++ b/agent_api_rest/src/holder/openid4vci/mod.rs @@ -12,7 +12,21 @@ use serde_json::Value; use tracing::info; use utoipa::ToSchema; -#[derive(Deserialize, Serialize, ToSchema)] +#[derive(ToSchema)] +#[schema(as = CredentialOffer)] +pub struct CredentialOfferSchema { + pub foo: String, + pub bar: i32, +} + +#[derive(ToSchema)] +#[schema(as = Oid4vciOfferEndpointRequest)] +pub struct Oid4vciOfferEndpointRequestSchema { + pub foo: String, + pub bar: i32, +} + +#[derive(Deserialize, Serialize)] pub struct Oid4vciOfferEndpointRequest { #[serde(flatten)] pub credential_offer: CredentialOffer, @@ -26,7 +40,7 @@ pub struct Oid4vciOfferEndpointRequest { #[utoipa::path( get, path = "/openid4vci/offers", - request_body = Oid4vciOfferEndpointRequest, + request_body = Oid4vciOfferEndpointRequestSchema, tag = "Holder", tags = ["(public)"], responses( diff --git a/agent_api_rest/src/issuance/credential_issuer/credential.rs b/agent_api_rest/src/issuance/credential_issuer/credential.rs index 05dc2f31..116b88f4 100644 --- a/agent_api_rest/src/issuance/credential_issuer/credential.rs +++ b/agent_api_rest/src/issuance/credential_issuer/credential.rs @@ -16,14 +16,29 @@ use axum::{ response::{IntoResponse, Response}, }; use axum_auth::AuthBearer; -use oid4vci::credential_request::CredentialRequest; +use oid4vci::{credential_request::CredentialRequest, credential_response::CredentialResponse}; use serde_json::json; use tokio::time::sleep; use tracing::{error, info}; +use utoipa::ToSchema; const DEFAULT_EXTERNAL_SERVER_RESPONSE_TIMEOUT_MS: u64 = 1000; const POLLING_INTERVAL_MS: u64 = 100; +#[derive(ToSchema)] +#[schema(as = CredentialRequest)] +pub struct CredentialRequestSchema { + pub foo: String, + pub bar: i32, +} + +#[derive(ToSchema)] +#[schema(as = CredentialResponse)] +pub struct CredentialResponseSchema { + pub foo: String, + pub bar: i32, +} + /// Credential Endpoint /// /// Standard OpenID4VCI endpoint for redeeming a token for a credential. @@ -32,11 +47,11 @@ const POLLING_INTERVAL_MS: u64 = 100; path = "/openid4vci/credential", // TODO: doesn't work since (external) `CredentialRequest` doesn't implement `ToSchema`? // See: https://github.com/juhaku/utoipa?tab=readme-ov-file#how-to-implement-toschema-for-external-type - request_body = CredentialRequest, + request_body = CredentialRequestSchema, tag = "Issuance", tags = ["(public)"], responses( - (status = 200, description = "Successfully returns the credential", body = [CredentialResponse]) + (status = 200, description = "Successfully returns the credential", body = [CredentialResponseSchema]) ) )] #[axum_macros::debug_handler] diff --git a/agent_api_rest/src/issuance/credential_issuer/token.rs b/agent_api_rest/src/issuance/credential_issuer/token.rs index c6fd8092..dde7c340 100644 --- a/agent_api_rest/src/issuance/credential_issuer/token.rs +++ b/agent_api_rest/src/issuance/credential_issuer/token.rs @@ -12,6 +12,14 @@ use axum::{ use oid4vci::token_request::TokenRequest; use serde_json::json; use tracing::info; +use utoipa::ToSchema; + +#[derive(ToSchema)] +#[schema(as = TokenRequest)] +pub struct TokenRequestSchema { + pub foo: String, + pub bar: i32, +} /// Token Endpoint /// @@ -19,6 +27,7 @@ use tracing::info; #[utoipa::path( post, path = "/auth/token", + request_body = TokenRequestSchema, tags = ["(public)"], responses( (status = 200, description = "Returns an access token."), diff --git a/agent_api_rest/src/issuance/credential_issuer/well_known/oauth_authorization_server.rs b/agent_api_rest/src/issuance/credential_issuer/well_known/oauth_authorization_server.rs index d99ba393..52c8735c 100644 --- a/agent_api_rest/src/issuance/credential_issuer/well_known/oauth_authorization_server.rs +++ b/agent_api_rest/src/issuance/credential_issuer/well_known/oauth_authorization_server.rs @@ -8,6 +8,15 @@ use axum::{ http::StatusCode, response::{IntoResponse, Response}, }; +use oid4vci::credential_issuer::authorization_server_metadata::AuthorizationServerMetadata; +use utoipa::ToSchema; + +#[derive(ToSchema)] +#[schema(as = AuthorizationServerMetadata)] +pub struct AuthorizationServerMetadataSchema { + pub foo: String, + pub bar: i32, +} /// Authorization Server Metadata /// @@ -18,7 +27,7 @@ use axum::{ tag = "(.well-known)", tags = ["(public)"], responses( - (status = 200, description = "Successfully returns the Authorization Server Metadata", body = [AuthorizationServerMetadata]) + (status = 200, description = "Successfully returns the Authorization Server Metadata", body = [AuthorizationServerMetadataSchema]) ) )] #[axum_macros::debug_handler] diff --git a/agent_api_rest/src/issuance/credential_issuer/well_known/openid_credential_issuer.rs b/agent_api_rest/src/issuance/credential_issuer/well_known/openid_credential_issuer.rs index c95bcd9b..0ea586e5 100644 --- a/agent_api_rest/src/issuance/credential_issuer/well_known/openid_credential_issuer.rs +++ b/agent_api_rest/src/issuance/credential_issuer/well_known/openid_credential_issuer.rs @@ -8,6 +8,15 @@ use axum::{ http::StatusCode, response::{IntoResponse, Response}, }; +use oid4vci::credential_issuer::credential_issuer_metadata::CredentialIssuerMetadata; +use utoipa::ToSchema; + +#[derive(ToSchema)] +#[schema(as = CredentialIssuerMetadata)] +pub struct CredentialIssuerMetadataSchema { + pub foo: String, + pub bar: i32, +} /// Credential Issuer Metadata /// @@ -18,7 +27,7 @@ use axum::{ tag = "(.well-known)", tags = ["(public)"], responses( - (status = 200, description = "Successfully returns the Credential Issuer Metadata", body = [CredentialIssuerMetadata]) + (status = 200, description = "Successfully returns the Credential Issuer Metadata", body = [CredentialIssuerMetadataSchema]) ) )] #[axum_macros::debug_handler] diff --git a/agent_api_rest/src/issuance/credentials.rs b/agent_api_rest/src/issuance/credentials.rs index 176f243a..2d87c89f 100644 --- a/agent_api_rest/src/issuance/credentials.rs +++ b/agent_api_rest/src/issuance/credentials.rs @@ -19,6 +19,13 @@ use serde_json::Value; use tracing::info; use utoipa::ToSchema; +#[derive(ToSchema)] +#[schema(as = CredentialView)] +pub struct CredentialViewSchema { + pub foo: String, + pub bar: i32, +} + /// Retrieve a credential /// /// Retrieves an existing credential by its ID. @@ -30,7 +37,7 @@ use utoipa::ToSchema; ("id" = String, Path, description = "Unique identifier of the Credential", example = "0001"), ), responses( - (status = 200, description = "Credential found", body = [CredentialView]) + (status = 200, description = "Credential found", body = [CredentialViewSchema]) ) )] #[axum_macros::debug_handler] @@ -66,7 +73,7 @@ pub struct CredentialsEndpointRequest { ), tag = "Issuance", responses( - (status = 201, description = "Successfully created a new credential.", body = CredentialView, + (status = 201, description = "Successfully created a new credential.", body = CredentialViewSchema, headers(("Location" = String, description = "URL of the created resource")), examples( ("w3c-vc-1-1" = (summary = "W3C VC Data Model v1.1", description = "A credential following the W3C Verifiable Credentials Data Model v1.1", value = json!({"offerId": "0001"}))), diff --git a/agent_api_rest/src/issuance/offers/send.rs b/agent_api_rest/src/issuance/offers/send.rs index 10f9b0a4..a8a79a11 100644 --- a/agent_api_rest/src/issuance/offers/send.rs +++ b/agent_api_rest/src/issuance/offers/send.rs @@ -11,7 +11,13 @@ use tracing::info; use url::Url; use utoipa::ToSchema; -#[derive(Deserialize, Serialize, ToSchema)] +#[derive(ToSchema)] +pub struct SendOfferEndpointRequestSchema { + pub offer_id: String, + pub target_url: String, +} + +#[derive(Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SendOfferEndpointRequest { pub offer_id: String, @@ -25,7 +31,7 @@ pub struct SendOfferEndpointRequest { #[utoipa::path( post, path = "/offers/send", - request_body(content = SendOfferEndpointRequest, example = json!({"offerId": "0001", "targetUrl": "https://wallet.example.com/openid4vci/offers"})), + request_body(content = SendOfferEndpointRequestSchema, example = json!({"offerId": "0001", "targetUrl": "https://wallet.example.com/openid4vci/offers"})), tag = "Issuance", responses( (status = 200, description = "Successfully sent credential offer to Holder."), diff --git a/agent_api_rest/src/lib.rs b/agent_api_rest/src/lib.rs index ee736862..e1fcd5c8 100644 --- a/agent_api_rest/src/lib.rs +++ b/agent_api_rest/src/lib.rs @@ -13,7 +13,7 @@ use axum::{body::Bytes, extract::MatchedPath, http::Request, response::Response, use std::time::Duration; use tower_http::{cors::CorsLayer, trace::TraceLayer}; use tracing::{info, info_span, Span}; -use utoipa::OpenApi; +use utoipa::{openapi::HttpMethod, OpenApi}; use utoipa_scalar::{Scalar, Servable}; use crate::openapi::{did_configuration, did_web, HolderApi, IssuanceApi, VerificationApi}; @@ -107,7 +107,7 @@ fn get_base_path() -> Result { }) } -#[derive(utoipa::OpenApi)] +#[derive(OpenApi)] #[openapi( // modifiers(), paths( @@ -117,7 +117,7 @@ fn get_base_path() -> Result { crate::verification::relying_party::request::request, crate::issuance::credential_issuer::token::token, // OpenID4VCI - crate::holder::openid4vci::offers, + crate::holder::openid4vci::offers_params, crate::issuance::credential_issuer::credential::credential, // .well-known crate::issuance::credential_issuer::well_known::oauth_authorization_server::oauth_authorization_server, @@ -148,11 +148,18 @@ pub fn patch_generated_openapi(mut openapi: utoipa::openapi::OpenApi) -> utoipa: // .description(Some("UniCore development server hosted by Impierce Technologies")) // .build()] // .into(); + // Append endpoints defined outside of `agent_api_rest`. - openapi.paths.add_path("/.well-known/did.json", did_web()); openapi .paths - .add_path("/.well-known/did-configuration.json", did_configuration()); + .add_path_operation("/.well-known/did.json", vec![HttpMethod::Get], did_web()); + + openapi.paths.add_path_operation( + "/.well-known/did-configuration.json", + vec![HttpMethod::Get], + did_configuration(), + ); + openapi } @@ -215,6 +222,7 @@ mod tests { async fn handler() {} #[tokio::test] + #[ignore = "Execute this test manually to generate the openapi.yaml file"] async fn generate_openapi_file() { let yaml_value = patch_generated_openapi(ApiDoc::openapi()); let yaml_string = serde_yaml::to_string(&yaml_value).unwrap(); diff --git a/agent_api_rest/src/openapi.rs b/agent_api_rest/src/openapi.rs index 36a9dcf7..446dbf39 100644 --- a/agent_api_rest/src/openapi.rs +++ b/agent_api_rest/src/openapi.rs @@ -1,3 +1,4 @@ +use utoipa::openapi::path::Operation; use utoipa::openapi::{ path::OperationBuilder, Content, HttpMethod, PathItem, Ref, Response, ResponseBuilder, ResponsesBuilder, }; @@ -11,15 +12,15 @@ use crate::verification::authorization_requests; #[derive(OpenApi)] #[openapi( paths( + credentials::credential, credentials::credentials, - credentials::get_credentials, offers::offers, - offers::send::send + offers::send::send, ), components(schemas( credentials::CredentialsEndpointRequest, offers::OffersEndpointRequest, - offers::send::SendOfferEndpointRequest + offers::send::SendOfferEndpointRequestSchema )) )] pub(crate) struct IssuanceApi; @@ -27,10 +28,10 @@ pub(crate) struct IssuanceApi; #[derive(OpenApi)] #[openapi( paths( - authorization_requests::authorization_requests, - authorization_requests::get_authorization_requests + authorization_requests::all_authorization_requests, + authorization_requests::authorization_requests ), - components(schemas(authorization_requests::AuthorizationRequestsEndpointRequest)) + components(schemas(authorization_requests::AuthorizationRequestsEndpointRequestSchema)) )] pub(crate) struct VerificationApi; @@ -42,56 +43,55 @@ pub(crate) struct VerificationApi; holder::offers::accept::accept, holder::offers::reject::reject ), - components(schemas(openid4vci::Oid4vciOfferEndpointRequest)) + components(schemas(openid4vci::Oid4vciOfferEndpointRequestSchema)) )] pub(crate) struct HolderApi; -pub(crate) fn did_web() -> PathItem { - PathItem::new( - HttpMethod::Get, - OperationBuilder::new() - .responses( - ResponsesBuilder::new() - .response( - "200", - ResponseBuilder::new() - .description("DID Document for `did:web` method") - .content("application/json", Content::new(Ref::from_schema_name("CoreDocument"))), - ) - .response("404", Response::new("DID method `did:web` inactive.")), - ) - .operation_id(Some("did_json")) - .summary(Some("DID Document for `did:web` method")) - .description(Some("Standard .well-known endpoint for self-hosted DID Document.")) - .tags(Some(vec!["(.well-known)", "(public)"])), - ) +pub(crate) fn did_web() -> Operation { + OperationBuilder::new() + .responses( + ResponsesBuilder::new() + .response( + "200", + ResponseBuilder::new() + .description("DID Document for `did:web` method") + .content( + "application/json", + Content::new(Some(Ref::from_schema_name("CoreDocument"))), + ), + ) + .response("404", Response::new("DID method `did:web` inactive.")), + ) + .operation_id(Some("did_json")) + .summary(Some("DID Document for `did:web` method")) + .description(Some("Standard .well-known endpoint for self-hosted DID Document.")) + .tags(Some(vec!["(.well-known)", "(public)"])) + .build() } -pub(crate) fn did_configuration() -> PathItem { - PathItem::new( - HttpMethod::Get, - OperationBuilder::new() - .responses( - ResponsesBuilder::new() - .response( - "200", - ResponseBuilder::new() - .description("DID Configuration Resource") - .content( - "application/json", - Content::new(Ref::from_schema_name("DomainLinkageConfiguration")), - // Content::new( - // ObjectBuilder::new() - // .schema_type(SchemaType::Type(schema::Type::Object)) - // .format(Some(schema::SchemaFormat::KnownFormat(schema::KnownFormat::Int64))), - // ), - ), - ) - .response("404", Response::new("Domain Linkage inactive.")), - ) - .operation_id(Some("did_configuration_json")) - .summary(Some("DID Configuration Resource for Domain Linkage")) - .description(Some("Standard .well-known endpoint for DID Configuration Resources.")) - .tags(Some(vec!["(.well-known)", "(public)"])), - ) +pub(crate) fn did_configuration() -> Operation { + OperationBuilder::new() + .responses( + ResponsesBuilder::new() + .response( + "200", + ResponseBuilder::new() + .description("DID Configuration Resource") + .content( + "application/json", + Content::new(Some(Ref::from_schema_name("DomainLinkageConfiguration"))), + // Content::new( + // ObjectBuilder::new() + // .schema_type(SchemaType::Type(schema::Type::Object)) + // .format(Some(schema::SchemaFormat::KnownFormat(schema::KnownFormat::Int64))), + // ), + ), + ) + .response("404", Response::new("Domain Linkage inactive.")), + ) + .operation_id(Some("did_configuration_json")) + .summary(Some("DID Configuration Resource for Domain Linkage")) + .description(Some("Standard .well-known endpoint for DID Configuration Resources.")) + .tags(Some(vec!["(.well-known)", "(public)"])) + .build() } diff --git a/agent_api_rest/src/verification/authorization_requests.rs b/agent_api_rest/src/verification/authorization_requests.rs index f6006d74..37d446b3 100644 --- a/agent_api_rest/src/verification/authorization_requests.rs +++ b/agent_api_rest/src/verification/authorization_requests.rs @@ -5,6 +5,7 @@ use agent_shared::{ }; use agent_verification::{ authorization_request::{command::AuthorizationRequestCommand, views::AuthorizationRequestView}, + generic_oid4vc::GenericAuthorizationRequest, state::VerificationState, }; use axum::{ @@ -20,6 +21,27 @@ use serde_json::{json, Value}; use tracing::info; use utoipa::ToSchema; +#[derive(ToSchema)] +#[schema(as = GenericAuthorizationRequest)] +pub struct GenericAuthorizationRequestSchema { + pub foo: String, + pub bar: i32, +} + +// #[derive(ToSchema)] +// #[schema(as = PresentationDefinitionResource)] +// pub struct PresentationDefinitionResourceSchema { +// pub foo: String, +// pub bar: i32, +// } + +#[derive(ToSchema)] +#[schema(as = AuthorizationRequestsEndpointRequest)] +pub struct AuthorizationRequestsEndpointRequestSchema { + pub foo: String, + pub bar: i32, +} + /// Get an Authorization Request /// /// Retrieve an existing Authorization Request. @@ -31,7 +53,7 @@ use utoipa::ToSchema; ("id" = String, Path, description = "The ID of the Authorization Request to retrieve.") ), responses( - (status = 200, description = "Successfully returns an existing Authorization Request.", body = [GenericAuthorizationRequest]) + (status = 200, description = "Successfully returns an existing Authorization Request.", body = [GenericAuthorizationRequestSchema]) ) )] #[axum_macros::debug_handler] @@ -62,7 +84,7 @@ pub(crate) async fn authorization_request( } } -#[derive(Deserialize, Serialize, ToSchema)] +#[derive(Deserialize, Serialize)] pub struct AuthorizationRequestsEndpointRequest { pub nonce: String, pub state: Option, @@ -83,7 +105,7 @@ pub enum PresentationDefinitionResource { #[utoipa::path( post, path = "/authorization_requests", - request_body = AuthorizationRequestsEndpointRequest, + request_body = AuthorizationRequestsEndpointRequestSchema, tag = "Verification", responses( (status = 201, description = "Authorization Request successfully created."), diff --git a/agent_api_rest/src/verification/relying_party/redirect.rs b/agent_api_rest/src/verification/relying_party/redirect.rs index 8e1625ac..5267899a 100644 --- a/agent_api_rest/src/verification/relying_party/redirect.rs +++ b/agent_api_rest/src/verification/relying_party/redirect.rs @@ -10,6 +10,14 @@ use axum::{ response::{IntoResponse, Response}, Form, }; +use utoipa::ToSchema; + +#[derive(ToSchema)] +#[schema(as = GenericAuthorizationResponse)] +pub struct GenericAuthorizationResponseSchema { + pub foo: String, + pub bar: i32, +} /// Redirect Endpoint /// @@ -17,6 +25,7 @@ use axum::{ #[utoipa::path( post, path = "/redirect", + request_body = GenericAuthorizationResponseSchema, tags = ["(public)"], responses( (status = 200, description = ""), diff --git a/agent_application/src/main.rs b/agent_application/src/main.rs index e1e148bc..9085a678 100644 --- a/agent_application/src/main.rs +++ b/agent_application/src/main.rs @@ -10,7 +10,7 @@ use agent_shared::config::{config, LogFormat}; use agent_store::{in_memory, postgres, EventPublisher}; use agent_verification::services::VerificationServices; use std::sync::Arc; -use tokio::{fs, io}; +use tokio::io; use tracing::info; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};