diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ccf7088d..cc9ed340 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ name: CI env: PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['version'] }} - URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['artifacts']['openapi.json'] }} + URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['artifacts']['openapi-3.1.json'] }} VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }} jobs: @@ -44,6 +44,7 @@ jobs: - uses: vrchatapi/specification/.github/actions/download@main with: + bundle: openapi-3.1.json url: ${{ env.URL }} - if: env.PASSED_VERSION != '' diff --git a/examples/cookies_load.rs b/examples/cookies_load.rs index 0dc9d5e7..177733ad 100644 --- a/examples/cookies_load.rs +++ b/examples/cookies_load.rs @@ -31,10 +31,10 @@ async fn main() { .unwrap(); match user { - ::vrchatapi::models::RegisterUserAccount200Response::CurrentUser(user) => { + ::vrchatapi::models::CurrentUserLoginResponse::CurrentUser(user) => { println!("Current user: {}", user.display_name) } - ::vrchatapi::models::RegisterUserAccount200Response::RequiresTwoFactorAuth(_) => { + ::vrchatapi::models::CurrentUserLoginResponse::RequiresTwoFactorAuth(_) => { println!("cookie invalid") } } diff --git a/examples/cookies_store.rs b/examples/cookies_store.rs index 863077b0..0af8dd65 100644 --- a/examples/cookies_store.rs +++ b/examples/cookies_store.rs @@ -18,12 +18,10 @@ async fn main() { .await .unwrap() { - ::vrchatapi::models::RegisterUserAccount200Response::CurrentUser(me) => { + ::vrchatapi::models::CurrentUserLoginResponse::CurrentUser(me) => { println!("Username: {}", me.username.unwrap()) } - ::vrchatapi::models::RegisterUserAccount200Response::RequiresTwoFactorAuth( - requires_auth, - ) => { + ::vrchatapi::models::CurrentUserLoginResponse::RequiresTwoFactorAuth(requires_auth) => { if requires_auth .requires_two_factor_auth .contains(&::vrchatapi::models::TwoFactorAuthType::EmailOtp) @@ -56,10 +54,10 @@ async fn main() { .unwrap(); match user { - ::vrchatapi::models::RegisterUserAccount200Response::CurrentUser(user) => { + ::vrchatapi::models::CurrentUserLoginResponse::CurrentUser(user) => { println!("Current user: {}", user.display_name) } - ::vrchatapi::models::RegisterUserAccount200Response::RequiresTwoFactorAuth(_) => { + ::vrchatapi::models::CurrentUserLoginResponse::RequiresTwoFactorAuth(_) => { println!("cookie invalid") } } diff --git a/examples/example.rs b/examples/example.rs index 0eacae38..5264a536 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -7,12 +7,10 @@ async fn main() { .await .unwrap() { - ::vrchatapi::models::RegisterUserAccount200Response::CurrentUser(me) => { + ::vrchatapi::models::CurrentUserLoginResponse::CurrentUser(me) => { println!("Username: {}", me.username.unwrap()) } - ::vrchatapi::models::RegisterUserAccount200Response::RequiresTwoFactorAuth( - requires_auth, - ) => { + ::vrchatapi::models::CurrentUserLoginResponse::RequiresTwoFactorAuth(requires_auth) => { if requires_auth .requires_two_factor_auth .contains(&::vrchatapi::models::TwoFactorAuthType::EmailOtp) @@ -45,10 +43,10 @@ async fn main() { .unwrap(); match user { - ::vrchatapi::models::RegisterUserAccount200Response::CurrentUser(user) => { + ::vrchatapi::models::CurrentUserLoginResponse::CurrentUser(user) => { println!("Current user: {}", user.display_name) } - ::vrchatapi::models::RegisterUserAccount200Response::RequiresTwoFactorAuth(_) => { + ::vrchatapi::models::CurrentUserLoginResponse::RequiresTwoFactorAuth(_) => { println!("cookie invalid") } } diff --git a/templates/model.mustache b/templates/model.mustache index 4c6c4106..17adc162 100644 --- a/templates/model.mustache +++ b/templates/model.mustache @@ -123,9 +123,14 @@ impl Default for {{classname}} { {{!-- for non-enum schemas --}} {{^isEnum}} {{^discriminator}} -{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as] -{{/vendorExtensions.x-rust-has-byte-array}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +{{^composedSchemas.allOf}}{{! +}}{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as] +{{/vendorExtensions.x-rust-has-byte-array}}{{^vendorExtensions.x-rust-has-byte-array}}{{#vendorExtensions.x-vrcapispecification-has-double-json-encoding}}#[serde_with::serde_as] +{{/vendorExtensions.x-vrcapispecification-has-double-json-encoding}}{{/vendorExtensions.x-rust-has-byte-array}}{{! +}}{{/composedSchemas.allOf}}{{! +}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct {{{classname}}} { +{{^composedSchemas.allOf}} {{#vars}} {{#description}} /// {{{.}}} @@ -133,6 +138,8 @@ pub struct {{{classname}}} { {{#isByteArray}} {{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}")]{{/vendorExtensions.isMandatory}} {{/isByteArray}} + {{#vendorExtensions.x-double-encoding}}#[serde_as(as = "serde_with::json::JsonString")] + {{/vendorExtensions.x-double-encoding}} #[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})] pub {{{name}}}: {{! ### Option Start @@ -144,14 +151,22 @@ pub struct {{{classname}}} { ### Models }}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{! ### Primative datatypes + }}{{^vendorExtensions.x-vrchat-double-encoding-type}}{{! }}{{^isModel}}{{#isByteArray}}Vec{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{! + }}{{/vendorExtensions.x-vrchat-double-encoding-type}}{{#vendorExtensions.x-vrchat-double-encoding-type}}models::{{{vendorExtensions.x-vrchat-double-encoding-type}}}{{/vendorExtensions.x-vrchat-double-encoding-type}}{{! ### Non-Enums End }}{{/isEnum}}{{! ### Option End (and trailing comma) }}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}}, {{/vars}} +{{/composedSchemas.allOf}} +{{#composedSchemas.allOf}} + #[serde(flatten)] + pub {{#title}}{{{title}}}{{/title}}{{^title}}{{{name}}}{{/title}}: {{{dataType}}}, +{{/composedSchemas.allOf}} } +{{^composedSchemas.allOf}} impl {{{classname}}} { {{#description}} /// {{{.}}} @@ -174,6 +189,7 @@ impl {{{classname}}} { } } } +{{/composedSchemas.allOf}} {{/oneOf.isEmpty}} {{^oneOf.isEmpty}} {{! TODO: add other vars that are not part of the oneOf}}