From a96b24fe9d5f77fec09f920832d60b382561aad5 Mon Sep 17 00:00:00 2001 From: Sergey Sova Date: Sun, 22 Mar 2020 19:50:00 +0300 Subject: [PATCH] test(cargo-swagg): add snapshot tests for components --- cargo-swagg/src/main.rs | 289 ----------- cargo-swagg/src/printer/components/module.rs | 24 + .../src/printer/components/parameters.rs | 26 + .../src/printer/components/request_bodies.rs | 26 + .../src/printer/components/responses.rs | 26 + cargo-swagg/src/printer/mod.rs | 491 ++++++++++++++++++ 6 files changed, 593 insertions(+), 289 deletions(-) diff --git a/cargo-swagg/src/main.rs b/cargo-swagg/src/main.rs index ef11241..0cbadf7 100644 --- a/cargo-swagg/src/main.rs +++ b/cargo-swagg/src/main.rs @@ -3,16 +3,6 @@ use std::fs; mod printer; -use printer::{ - api::{ApiModule, ApiStruct, BindApiMethod, HttpMethod, ImplApi}, - components::{ - parameters::ParametersModule, request_bodies::RequestBodiesModule, responses::ResponsesModule, Component, - ComponentsModule, EnumVariant, Field, FieldType, FormatFloat, FormatInteger, FormatString, NativeType, - }, - paths::{ContentType, Path, PathsModule, QueryParam, ResponseEnum, ResponseStatus, StatusVariant}, - GeneratedModule, Printable, -}; - #[cfg(test)] pub mod test; @@ -23,284 +13,5 @@ fn main() -> Result<(), Box> { // println!("{}", "OAuthAuthorizeRequest".to_snake_case()); - let api: ApiStruct = api.info.into(); - - let m1 = BindApiMethod { - method: HttpMethod::Get, - name: "sessionGet".to_owned(), - path: "/session".to_owned(), - request_body: None, - }; - - let m2 = BindApiMethod { - method: HttpMethod::Post, - name: "sessionCreate".to_owned(), - path: "/session".to_owned(), - request_body: Some("SessionCreateBody".to_owned()), - }; - - let m3 = BindApiMethod { - method: HttpMethod::Post, - name: "registerConfirmation".to_owned(), - path: "/register/confirmation".to_owned(), - request_body: Some("RegisterConfirmation".to_owned()), - }; - - let methods = ImplApi { - api_name: api.api_name.clone(), - methods: vec![m1, m2, m3], - }; - - let api_module = ApiModule { api, methods }; - - let components_module = - ComponentsModule { - parameters: ParametersModule { - list: vec![ - Component::Enum { - name: "OAuthResponseType".to_owned(), - description: Some( - "response_type is set to code indicating that you want an authorization code as the response." - .to_owned(), - ), - variants: vec![EnumVariant { - name: "code".to_owned(), - description: None, - }], - }, - Component::Type { - name: "OAuthClientId".to_owned(), - description: Some("The client_id is the identifier for your app".to_owned()), - type_value: FieldType::Internal("uuid::Uuid".to_owned()), - }, - Component::Type { - name: "OAuthRedirectUri".to_owned(), - description: Some( - "redirect_uri may be optional depending on the API, but is highly recommended".to_owned(), - ), - type_value: FieldType::Native(NativeType::String { format: Default::default() }), - }, - ], - }, - responses: ResponsesModule { - list: vec![ - Component::Object { - name: "RegisterConfirmationFailed".to_owned(), - fields: vec![Field { - name: "error".to_owned(), - required: true, - description: None, - field_type: FieldType::Custom("RegisterConfirmationFailedError".to_owned()), - }], - description: Some("Answer for registration confirmation".to_owned()), - }, - Component::Enum { - name: "RegisterConfirmationFailedError".to_owned(), - variants: vec![ - EnumVariant { - name: "code_invalid_or_expired".to_owned(), - description: None, - }, - EnumVariant { - name: "email_already_activated".to_owned(), - description: None, - }, - EnumVariant { - name: "invalid_form".to_owned(), - description: None, - }, - ], - description: None, - }, - Component::Object { - name: "RegistrationRequestCreated".to_owned(), - description: Some( - "Registration link sent to email, now user can find out when the link expires".to_owned(), - ), - fields: vec![Field { - name: "expiresAt".to_owned(), - required: true, - description: Some("UTC Unix TimeStamp when the link expires".to_owned()), - field_type: FieldType::Native(NativeType::Integer { - format: FormatInteger::Int64, - }), - }], - }, - ], - }, - request_bodies: RequestBodiesModule { - list: vec![ - Component::Object { - name: "Register".to_owned(), - description: None, - fields: vec![ - Field { - name: "email".to_owned(), - required: true, - description: None, - field_type: FieldType::Native(NativeType::String { - format: FormatString::Email, - }), - }, - Field { - name: "demo".to_owned(), - required: false, - description: None, - field_type: FieldType::Array(Box::new(FieldType::Array(Box::new(FieldType::Native( - NativeType::String { - format: FormatString::Email, - }, - ))))), - }, - ], - }, - Component::Object { - name: "RegisterConfirmation".to_owned(), - description: None, - fields: vec![ - Field { - name: "confirmationCode".to_owned(), - required: true, - description: None, - field_type: FieldType::Native(NativeType::String { - format: FormatString::default(), - }), - }, - Field { - name: "firstName".to_owned(), - required: true, - description: None, - field_type: FieldType::Native(NativeType::String { - format: FormatString::default(), - }), - }, - Field { - name: "lastName".to_owned(), - required: true, - description: None, - field_type: FieldType::Native(NativeType::String { - format: FormatString::default(), - }), - }, - Field { - name: "password".to_owned(), - required: true, - description: None, - field_type: FieldType::Native(NativeType::String { - format: FormatString::default(), - }), - }, - Field { - name: "demo".to_owned(), - required: false, - description: None, - field_type: FieldType::Native(NativeType::Float { - format: FormatFloat::default(), - }), - }, - Field { - name: "customizer".to_owned(), - required: false, - description: None, - field_type: FieldType::Internal("crate::app::MySuperType".to_owned()), - }, - ], - }, - ], - }, - }; - - let p1 = Path { - name: "registerConfirmation".to_owned(), - query_params: vec![], - response: ResponseEnum { - responses: vec![ - StatusVariant { - status: ResponseStatus::Created, - response_type_name: None, - description: None, - content_type: None, - x_variant_name: None, - }, - StatusVariant { - status: ResponseStatus::BadRequest, - response_type_name: Some("RegisterConfirmationFailed".to_owned()), - description: None, - content_type: Some(ContentType::Json), - x_variant_name: None, - }, - StatusVariant { - status: ResponseStatus::InternalServerError, - response_type_name: None, - description: None, - content_type: Some(ContentType::Json), - x_variant_name: Some("Unexpected".to_owned()), - }, - ], - }, - }; - - let p2 = Path { - name: "sessionCreate".to_owned(), - query_params: vec![ - QueryParam { - name: "responseType".to_owned(), - type_ref: "OAuthResponseType".to_owned(), - description: Some( - "response_type is set to code indicating that you want an authorization code as the response." - .to_owned(), - ), - required: true, - }, - QueryParam { - name: "redirect_uri".to_owned(), - type_ref: "OAuthRedirectUri".to_owned(), - description: None, - required: false, - }, - QueryParam { - name: "GlobalNameOfTheUniverse".to_owned(), - type_ref: "OAuthClientId".to_owned(), - description: None, - required: false, - }, - ], - response: ResponseEnum { - responses: vec![ - StatusVariant { - status: ResponseStatus::Created, - response_type_name: None, - description: Some("User logined, cookies writed\nFoo".to_owned()), - content_type: None, - x_variant_name: None, - }, - StatusVariant { - status: ResponseStatus::BadRequest, - response_type_name: Some("sessionCreateFailed".to_owned()), - description: None, - content_type: Some(ContentType::Json), - x_variant_name: None, - }, - StatusVariant { - status: ResponseStatus::InternalServerError, - response_type_name: None, - description: None, - content_type: Some(ContentType::Json), - x_variant_name: Some("Unexpected".to_owned()), - }, - ], - }, - }; - - let paths_module = PathsModule { paths: vec![p1, p2] }; - - let generated_module = GeneratedModule { - api_module, - components_module, - paths_module, - }; - - println!("{}", generated_module.print()); - Ok(()) } diff --git a/cargo-swagg/src/printer/components/module.rs b/cargo-swagg/src/printer/components/module.rs index 5e176ea..bbe2bca 100644 --- a/cargo-swagg/src/printer/components/module.rs +++ b/cargo-swagg/src/printer/components/module.rs @@ -26,3 +26,27 @@ impl Printable for ComponentsModule { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::test::shot; + use insta::assert_snapshot; + + #[test] + fn components_module_default() { + assert_snapshot!(shot(ComponentsModule::default()), @r###" + pub mod components { + pub mod parameters { + use serde::{Deserialize, Serialize}; + } + pub mod request_bodies { + use serde::{Deserialize, Serialize}; + } + pub mod responses { + use serde::{Deserialize, Serialize}; + } + } + "###); + } +} diff --git a/cargo-swagg/src/printer/components/parameters.rs b/cargo-swagg/src/printer/components/parameters.rs index dc578ac..c5acf62 100644 --- a/cargo-swagg/src/printer/components/parameters.rs +++ b/cargo-swagg/src/printer/components/parameters.rs @@ -24,3 +24,29 @@ pub mod module { } } } + +#[cfg(test)] +mod tests { + use super::super::Component; + use super::*; + use crate::test::shot; + use insta::assert_snapshot; + + #[test] + fn parameters_with_some_components() { + assert_snapshot!(shot(ParametersModule { + list: vec![ + Component::Enum { name: "Example".to_owned(), description: None, variants: vec![] }, + Component::Object { name: "Test".to_owned(), description: None, fields: vec![] }, + ] + }), @r###" + pub mod parameters { + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize, Deserialize)] + pub enum Example {} + #[derive(Debug, Serialize, Deserialize)] + pub struct Test {} + } + "###); + } +} diff --git a/cargo-swagg/src/printer/components/request_bodies.rs b/cargo-swagg/src/printer/components/request_bodies.rs index 67db2e0..784a00e 100644 --- a/cargo-swagg/src/printer/components/request_bodies.rs +++ b/cargo-swagg/src/printer/components/request_bodies.rs @@ -24,3 +24,29 @@ pub mod module { } } } + +#[cfg(test)] +mod tests { + use super::super::Component; + use super::*; + use crate::test::shot; + use insta::assert_snapshot; + + #[test] + fn request_bodies_with_some_components() { + assert_snapshot!(shot(RequestBodiesModule { + list: vec![ + Component::Enum { name: "Example".to_owned(), description: None, variants: vec![] }, + Component::Object { name: "Test".to_owned(), description: None, fields: vec![] }, + ] + }), @r###" + pub mod request_bodies { + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize, Deserialize)] + pub enum Example {} + #[derive(Debug, Serialize, Deserialize)] + pub struct Test {} + } + "###); + } +} diff --git a/cargo-swagg/src/printer/components/responses.rs b/cargo-swagg/src/printer/components/responses.rs index 926f2b5..3e37d98 100644 --- a/cargo-swagg/src/printer/components/responses.rs +++ b/cargo-swagg/src/printer/components/responses.rs @@ -24,3 +24,29 @@ pub mod module { } } } + +#[cfg(test)] +mod tests { + use super::super::Component; + use super::*; + use crate::test::shot; + use insta::assert_snapshot; + + #[test] + fn responses_with_some_components() { + assert_snapshot!(shot(ResponsesModule { + list: vec![ + Component::Enum { name: "Example".to_owned(), description: None, variants: vec![] }, + Component::Object { name: "Test".to_owned(), description: None, fields: vec![] }, + ] + }), @r###" + pub mod responses { + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize, Deserialize)] + pub enum Example {} + #[derive(Debug, Serialize, Deserialize)] + pub struct Test {} + } + "###); + } +} diff --git a/cargo-swagg/src/printer/mod.rs b/cargo-swagg/src/printer/mod.rs index aabbd26..5865ea9 100644 --- a/cargo-swagg/src/printer/mod.rs +++ b/cargo-swagg/src/printer/mod.rs @@ -41,3 +41,494 @@ impl Printable for GeneratedModule { } } } + +#[cfg(test)] +mod tests { + use super::{ + api::{ApiModule, ApiStruct, BindApiMethod, HttpMethod, ImplApi}, + components::{ + parameters::ParametersModule, request_bodies::RequestBodiesModule, responses::ResponsesModule, Component, + ComponentsModule, EnumVariant, Field, FieldType, FormatFloat, FormatInteger, FormatString, NativeType, + }, + paths::{ContentType, Path, PathsModule, QueryParam, ResponseEnum, ResponseStatus, StatusVariant}, + GeneratedModule, + }; + use crate::test::shot; + use insta::assert_snapshot; + + #[test] + fn huge_test_all_generated() { + let api: ApiStruct = ApiStruct { + api_name: "ExampleApiDef".to_owned(), + description: Some("Public API for frontend and OAuth applications [Review Github](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)".to_owned()), + terms_of_service: None, + }; + + let m1 = BindApiMethod { + method: HttpMethod::Get, + name: "sessionGet".to_owned(), + path: "/session".to_owned(), + request_body: None, + }; + + let m2 = BindApiMethod { + method: HttpMethod::Post, + name: "sessionCreate".to_owned(), + path: "/session".to_owned(), + request_body: Some("SessionCreateBody".to_owned()), + }; + + let m3 = BindApiMethod { + method: HttpMethod::Post, + name: "registerConfirmation".to_owned(), + path: "/register/confirmation".to_owned(), + request_body: Some("RegisterConfirmation".to_owned()), + }; + + let methods = ImplApi { + api_name: api.api_name.clone(), + methods: vec![m1, m2, m3], + }; + + let api_module = ApiModule { api, methods }; + + let components_module = ComponentsModule { + parameters: ParametersModule { + list: vec![ + Component::Enum { + name: "OAuthResponseType".to_owned(), + description: Some( + "response_type is set to code indicating that you want an authorization code as the response." + .to_owned(), + ), + variants: vec![EnumVariant { + name: "code".to_owned(), + description: None, + }], + }, + Component::Type { + name: "OAuthClientId".to_owned(), + description: Some("The client_id is the identifier for your app".to_owned()), + type_value: FieldType::Internal("uuid::Uuid".to_owned()), + }, + Component::Type { + name: "OAuthRedirectUri".to_owned(), + description: Some( + "redirect_uri may be optional depending on the API, but is highly recommended".to_owned(), + ), + type_value: FieldType::Native(NativeType::String { format: Default::default() }), + }, + ], + }, + responses: ResponsesModule { + list: vec![ + Component::Object { + name: "RegisterConfirmationFailed".to_owned(), + fields: vec![Field { + name: "error".to_owned(), + required: true, + description: None, + field_type: FieldType::Custom("RegisterConfirmationFailedError".to_owned()), + }], + description: Some("Answer for registration confirmation".to_owned()), + }, + Component::Enum { + name: "RegisterConfirmationFailedError".to_owned(), + variants: vec![ + EnumVariant { + name: "code_invalid_or_expired".to_owned(), + description: None, + }, + EnumVariant { + name: "email_already_activated".to_owned(), + description: None, + }, + EnumVariant { + name: "invalid_form".to_owned(), + description: None, + }, + ], + description: None, + }, + Component::Object { + name: "RegistrationRequestCreated".to_owned(), + description: Some( + "Registration link sent to email, now user can find out when the link expires".to_owned(), + ), + fields: vec![Field { + name: "expiresAt".to_owned(), + required: true, + description: Some("UTC Unix TimeStamp when the link expires".to_owned()), + field_type: FieldType::Native(NativeType::Integer { + format: FormatInteger::Int64, + }), + }], + }, + ], + }, + request_bodies: RequestBodiesModule { + list: vec![ + Component::Object { + name: "Register".to_owned(), + description: None, + fields: vec![ + Field { + name: "email".to_owned(), + required: true, + description: None, + field_type: FieldType::Native(NativeType::String { + format: FormatString::Email, + }), + }, + Field { + name: "demo".to_owned(), + required: false, + description: None, + field_type: FieldType::Array(Box::new(FieldType::Array(Box::new(FieldType::Native( + NativeType::String { + format: FormatString::Email, + }, + ))))), + }, + ], + }, + Component::Object { + name: "RegisterConfirmation".to_owned(), + description: None, + fields: vec![ + Field { + name: "confirmationCode".to_owned(), + required: true, + description: None, + field_type: FieldType::Native(NativeType::String { + format: FormatString::default(), + }), + }, + Field { + name: "firstName".to_owned(), + required: true, + description: None, + field_type: FieldType::Native(NativeType::String { + format: FormatString::default(), + }), + }, + Field { + name: "lastName".to_owned(), + required: true, + description: None, + field_type: FieldType::Native(NativeType::String { + format: FormatString::default(), + }), + }, + Field { + name: "password".to_owned(), + required: true, + description: None, + field_type: FieldType::Native(NativeType::String { + format: FormatString::default(), + }), + }, + Field { + name: "demo".to_owned(), + required: false, + description: None, + field_type: FieldType::Native(NativeType::Float { + format: FormatFloat::default(), + }), + }, + Field { + name: "customizer".to_owned(), + required: false, + description: None, + field_type: FieldType::Internal("crate::app::MySuperType".to_owned()), + }, + ], + }, + ], + }, + }; + + let p1 = Path { + name: "registerConfirmation".to_owned(), + query_params: vec![], + response: ResponseEnum { + responses: vec![ + StatusVariant { + status: ResponseStatus::Created, + response_type_name: None, + description: None, + content_type: None, + x_variant_name: None, + }, + StatusVariant { + status: ResponseStatus::BadRequest, + response_type_name: Some("RegisterConfirmationFailed".to_owned()), + description: None, + content_type: Some(ContentType::Json), + x_variant_name: None, + }, + StatusVariant { + status: ResponseStatus::InternalServerError, + response_type_name: None, + description: None, + content_type: Some(ContentType::Json), + x_variant_name: Some("Unexpected".to_owned()), + }, + ], + }, + }; + + let p2 = Path { + name: "sessionCreate".to_owned(), + query_params: vec![ + QueryParam { + name: "responseType".to_owned(), + type_ref: "OAuthResponseType".to_owned(), + description: Some( + "response_type is set to code indicating that you want an authorization code as the response." + .to_owned(), + ), + required: true, + }, + QueryParam { + name: "redirect_uri".to_owned(), + type_ref: "OAuthRedirectUri".to_owned(), + description: None, + required: false, + }, + QueryParam { + name: "GlobalNameOfTheUniverse".to_owned(), + type_ref: "OAuthClientId".to_owned(), + description: None, + required: false, + }, + ], + response: ResponseEnum { + responses: vec![ + StatusVariant { + status: ResponseStatus::Created, + response_type_name: None, + description: Some("User logined, cookies writed\nFoo".to_owned()), + content_type: None, + x_variant_name: None, + }, + StatusVariant { + status: ResponseStatus::BadRequest, + response_type_name: Some("sessionCreateFailed".to_owned()), + description: None, + content_type: Some(ContentType::Json), + x_variant_name: None, + }, + StatusVariant { + status: ResponseStatus::InternalServerError, + response_type_name: None, + description: None, + content_type: Some(ContentType::Json), + x_variant_name: Some("Unexpected".to_owned()), + }, + ], + }, + }; + + let paths_module = PathsModule { paths: vec![p1, p2] }; + + let generated_module = GeneratedModule { + api_module, + components_module, + paths_module, + }; + + assert_snapshot!(shot(generated_module), @r###" + pub mod api { + #[doc = "Public API for frontend and OAuth applications [Review Github](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)"] + pub struct ExampleApiDef { + api: actix_swagger::Api, + } + impl ExampleApiDef { + pub fn new() -> Self { + Self { + api: actix_swagger::Api::new(), + } + } + } + impl Default for ExampleApiDef { + fn default() -> Self { + let api = Self::new(); + api + } + } + impl actix_web::dev::HttpServiceFactory for ExampleApiDef { + fn register(mut self, config: &mut actix_web::dev::AppService) { + self.api.register(config); + } + } + use super::paths; + use actix_swagger::{Answer, Method}; + use actix_web::{dev::Factory, FromRequest}; + use std::future::Future; + impl ExampleApiDef { + pub fn bind_session_get(mut self, handler: F) -> Self + where + F: Factory>, + T: FromRequest + 'static, + R: Future> + 'static, + { + self.api = self.api.bind("/session".to_owned(), Method::GET, handler); + self + } + #[doc = "Request body - super::requst_bodies::SessionCreateBody"] + pub fn bind_session_create(mut self, handler: F) -> Self + where + F: Factory>, + T: FromRequest + 'static, + R: Future> + 'static, + { + self.api = self.api.bind("/session".to_owned(), Method::POST, handler); + self + } + #[doc = "Request body - super::requst_bodies::RegisterConfirmation"] + pub fn bind_register_confirmation(mut self, handler: F) -> Self + where + F: Factory>, + T: FromRequest + 'static, + R: Future> + 'static, + { + self.api = self + .api + .bind("/register/confirmation".to_owned(), Method::POST, handler); + self + } + } + } + pub mod components { + pub mod parameters { + use serde::{Deserialize, Serialize}; + #[doc = "response_type is set to code indicating that you want an authorization code as the response."] + #[derive(Debug, Serialize, Deserialize)] + pub enum OauthResponseType { + #[serde(rename = "code")] + Code, + } + #[doc = "The client_id is the identifier for your app"] + pub type OauthClientId = uuid::Uuid; + #[doc = "redirect_uri may be optional depending on the API, but is highly recommended"] + pub type OauthRedirectUri = String; + } + pub mod request_bodies { + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize, Deserialize)] + pub struct Register { + pub email: String, + pub demo: Option>>, + } + #[derive(Debug, Serialize, Deserialize)] + pub struct RegisterConfirmation { + #[serde(rename = "confirmationCode")] + pub confirmation_code: String, + #[serde(rename = "firstName")] + pub first_name: String, + #[serde(rename = "lastName")] + pub last_name: String, + pub password: String, + pub demo: Option, + pub customizer: Option, + } + } + pub mod responses { + use serde::{Deserialize, Serialize}; + #[doc = "Answer for registration confirmation"] + #[derive(Debug, Serialize, Deserialize)] + pub struct RegisterConfirmationFailed { + pub error: RegisterConfirmationFailedError, + } + #[derive(Debug, Serialize, Deserialize)] + pub enum RegisterConfirmationFailedError { + #[serde(rename = "code_invalid_or_expired")] + CodeInvalidOrExpired, + #[serde(rename = "email_already_activated")] + EmailAlreadyActivated, + #[serde(rename = "invalid_form")] + InvalidForm, + } + #[doc = "Registration link sent to email, now user can find out when the link expires"] + #[derive(Debug, Serialize, Deserialize)] + pub struct RegistrationRequestCreated { + #[doc = "UTC Unix TimeStamp when the link expires"] + #[serde(rename = "expiresAt")] + pub expires_at: i64, + } + } + } + pub mod paths { + pub mod register_confirmation { + use super::super::components::responses; + use actix_swagger::{Answer, ContentType, StatusCode}; + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize)] + #[serde(untagged)] + pub enum Response { + Created, + BadRequest(responses::RegisterConfirmationFailed), + Unexpected, + } + impl Response { + #[inline] + pub fn to_answer(self) -> Answer<'static, Self> { + let status = match self { + Self::Created => StatusCode::CREATED, + Self::BadRequest(_) => StatusCode::BAD_REQUEST, + Self::Unexpected => StatusCode::INTERNAL_SERVER_ERROR, + }; + let content_type = match self { + Self::Created => None, + Self::BadRequest(_) => Some(ContentType::Json), + Self::Unexpected => Some(ContentType::Json), + }; + Answer::new(self).status(status).content_type(content_type) + } + } + } + pub mod session_create { + use super::super::components::responses; + use actix_swagger::{Answer, ContentType, StatusCode}; + use serde::{Deserialize, Serialize}; + #[derive(Debug, Serialize)] + #[serde(untagged)] + pub enum Response { + #[doc = "User logined, cookies writed\nFoo"] + Created, + BadRequest(responses::SessionCreateFailed), + Unexpected, + } + impl Response { + #[inline] + pub fn to_answer(self) -> Answer<'static, Self> { + let status = match self { + Self::Created => StatusCode::CREATED, + Self::BadRequest(_) => StatusCode::BAD_REQUEST, + Self::Unexpected => StatusCode::INTERNAL_SERVER_ERROR, + }; + let content_type = match self { + Self::Created => None, + Self::BadRequest(_) => Some(ContentType::Json), + Self::Unexpected => Some(ContentType::Json), + }; + Answer::new(self).status(status).content_type(content_type) + } + } + use super::super::components::parameters; + #[derive(Debug, Deserialize)] + pub struct QueryParams { + #[doc = "response_type is set to code indicating that you want an authorization code as the response."] + #[serde(rename = "responseType")] + pub response_type: parameters::OauthResponseType, + pub redirect_uri: Option, + #[serde(rename = "GlobalNameOfTheUniverse")] + pub global_name_of_the_universe: Option, + } + pub type Query = actix_web::http::Query; + } + } + "###); + } +}