All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rust-axum.apis.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
use async_trait::async_trait;
use axum::extract::*;
use axum_extra::extract::{CookieJar, Multipart};
use bytes::Bytes;
use http::Method;
use serde::{Deserialize, Serialize};

use crate::{models, types::*};

{{#operations}}
{{#operation}}
{{>response}}
{{/operation}}
{{/operations}}

{{#operations}}
/// {{classnamePascalCase}}
#[async_trait]
#[allow(clippy::ptr_arg)]
pub trait {{classnamePascalCase}} {
{{#havingAuthMethod}}
  type Claims;

{{/havingAuthMethod}}
{{#operation}}
  {{#summary}}
    /// {{{.}}}.
    ///
  {{/summary}}
  {{#vendorExtensions}}
    /// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}}
    async fn {{{x-operation-id}}}(
    &self,
    method: Method,
    host: Host,
    cookies: CookieJar,
    {{#vendorExtensions}}
      {{#x-has-auth-methods}}
        claims: Self::Claims,
      {{/x-has-auth-methods}}
    {{/vendorExtensions}}
    {{#headerParams.size}}
      header_params: models::{{{operationIdCamelCase}}}HeaderParams,
    {{/headerParams.size}}
    {{#pathParams.size}}
      path_params: models::{{{operationIdCamelCase}}}PathParams,
    {{/pathParams.size}}
    {{#queryParams.size}}
      query_params: models::{{{operationIdCamelCase}}}QueryParams,
    {{/queryParams.size}}
    {{^x-consumes-multipart-related}}
    {{^x-consumes-multipart}}
      {{#bodyParam}}
      {{#vendorExtensions}}
        {{^x-consumes-plain-text}}
            body: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}},
        {{/x-consumes-plain-text}}
        {{#x-consumes-plain-text}}
          {{#isString}}
            body: String,
          {{/isString}}
          {{^isString}}
            body: Bytes,
          {{/isString}}
        {{/x-consumes-plain-text}}
      {{/vendorExtensions}}
      {{/bodyParam}}
    {{/x-consumes-multipart}}
    {{/x-consumes-multipart-related}}
    {{#x-consumes-multipart}}
        body: Multipart,
    {{/x-consumes-multipart}}
    {{#x-consumes-multipart-related}}
        body: axum::body::Body,
    {{/x-consumes-multipart-related}}
    ) -> Result<{{{operationId}}}Response, ()>;
  {{/vendorExtensions}}
  {{^-last}}

  {{/-last}}
{{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy