Open Pzixel opened 4 years ago
Openapi.yaml
x-generator: NSwag v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) openapi: 3.0.0 info: title: Settings API description: Settings and presets service version: v1 servers: - url: 'https://myUrl' paths: /: get: tags: - About operationId: About_Get responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MessageModel' /settings/api: get: tags: - About operationId: About_Get2 responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/MessageModel' /Healthcheck: get: tags: - Healthcheck operationId: Healthcheck_Get responses: '200': description: '' /settings/api/Healthcheck: get: tags: - Healthcheck operationId: Healthcheck_Get2 responses: '200': description: '' components: schemas: MessageModel: type: object additionalProperties: false properties: message: type: string nullable: true Integration: type: object additionalProperties: false properties: id: type: string format: guid createdBy: type: string format: guid createdOn: type: string format: date-time modifiedBy: type: string format: guid nullable: true modifiedOn: type: string format: date-time nullable: true deletedReason: type: string nullable: true deletedBy: type: string format: guid nullable: true deletedOn: type: string format: date-time nullable: true companyId: type: string format: guid title: type: string nullable: true securitySchemes: Bearer: type: apiKey description: Please insert Auth token into field name: Authorization in: header security: - Bearer: []
Command:
cargo-swagg ./openapi.yaml --out-file ./src/api.rs
Expected result:
Got API
Actual result:
#![allow(dead_code, unused_imports)] pub mod api { #[doc = "Settings and presets service"] pub struct SettingsApi { api: actix_swagger::Api, } impl SettingsApi { pub fn new() -> Self { Self { api: actix_swagger::Api::new(), } } } impl Default for SettingsApi { fn default() -> Self { let api = Self::new(); api } } impl actix_web::dev::HttpServiceFactory for SettingsApi { fn register(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 SettingsApi {} } 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}; } } pub mod paths { use super::components::{parameters, responses}; }
Openapi.yaml
Command:
Expected result:
Got API
Actual result: