Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 != ''
Expand Down
4 changes: 2 additions & 2 deletions examples/cookies_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
10 changes: 4 additions & 6 deletions examples/cookies_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
}
Expand Down
10 changes: 4 additions & 6 deletions examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
}
Expand Down
20 changes: 18 additions & 2 deletions templates/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,23 @@ 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}}
/// {{{.}}}
{{/description}}
{{#isByteArray}}
{{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}<serde_with::base64::Base64>")]{{/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
Expand All @@ -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<u8>{{/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}}
/// {{{.}}}
Expand All @@ -174,6 +189,7 @@ impl {{{classname}}} {
}
}
}
{{/composedSchemas.allOf}}
{{/oneOf.isEmpty}}
{{^oneOf.isEmpty}}
{{! TODO: add other vars that are not part of the oneOf}}
Expand Down
Loading