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

handlebars.aspnetcore.controller.mustache Maven / Gradle / Ivy

There is a newer version: 1.0.54
Show newest version
{{>partial_header}}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using {{packageName}}.Attributes;
{{#hasAuthMethods}}using {{packageName}}.Security;{{/hasAuthMethods}}
using {{packageName}}.Models;

namespace {{packageName}}.Controllers
{ {{#operations}}
    /// 
    /// {{description}}
    /// {{#description}}
    [Description("{{description}}")]{{/description}}
    public class {{classname}}Controller : Controller{{#interfaceController}}, I{{classname}}Controller{{/interfaceController}}
    { {{#operation}}
      {{#contents}}
        /// 
        /// {{#summary}}{{summary}}{{/summary}}
        /// 
        {{#notes}}/// {{notes}}{{/notes}}{{#parameters}}
        /// {{description}}{{/parameters}}{{#responses}}
        /// {{message}}{{/responses}}
        [{{httpMethod}}]
        [Route("{{{basePathWithoutHost}}}{{{path}}}")]
        {{#authMethods}}
        {{#@first}}
        {{#isBasic}}
        [Authorize(AuthenticationSchemes = BasicAuthenticationHandler.SchemeName)]
        {{/isBasic}}
        {{#isBearer}}
        [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
        {{/isBearer}}
        {{#isApiKey}}
        [Authorize(AuthenticationSchemes = ApiKeyAuthenticationHandler.SchemeName)]
        {{/isApiKey}}
        {{/@first}}
        {{/authMethods}}
        [ValidateModelState]
        [SwaggerOperation("{{operationId}}")]{{#responses}}{{#dataType}}
        [SwaggerResponse(statusCode: {{code}}, type: typeof({{&dataType}}), description: "{{message}}")]{{/dataType}}{{^dataType}}{{/dataType}}{{/responses}}
        public virtual IActionResult {{operationId}}({{#parameters}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/parameters}})
        { {{#responses}}
{{#dataType}}
            //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode({{code}}, default({{&dataType}}));
{{/dataType}}
{{^dataType}}
            //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode({{code}});
{{/dataType}}{{/responses}}
{{#returnType}}
            string exampleJson = null;
            {{#examples}}
            exampleJson = "{{{example}}}";
            {{/examples}}
            {{#isListCollection}}{{>listReturn}}{{/isListCollection}}{{^isListCollection}}{{#isMapContainer}}{{>mapReturn}}{{/isMapContainer}}{{^isMapContainer}}{{>objectReturn}}{{/isMapContainer}}{{/isListCollection}}
            {{!TODO: defaultResponse, examples, auth, consumes, produces, nickname, externalDocs, imports, security}}
            //TODO: Change the data returned
            return new ObjectResult(example);{{/returnType}}{{^returnType}}
            throw new NotImplementedException();{{/returnType}}
        }
        {{/contents}}
        {{/operation}}
    }
{{/operations}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy