From f90507b52768282f745bd75c886906c52315232d Mon Sep 17 00:00:00 2001 From: Doxoh Date: Tue, 30 Jul 2019 12:22:15 +0200 Subject: [PATCH] [aspnetcore] Support cookie parameter (#3490) * Fix typo useDefaultRoutng to useDefaultRouting * support the cookie functionality in aspnetcore * Changes like wing328 comments --- .../resources/aspnetcore/2.1/controller.mustache | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache index 0c136c8a8b8..99492c9a604 100644 --- a/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache +++ b/modules/openapi-generator/src/main/resources/aspnetcore/2.1/controller.mustache @@ -40,9 +40,14 @@ namespace {{apiPackage}} [SwaggerOperation("{{operationId}}")]{{#responses}}{{#dataType}} [SwaggerResponse(statusCode: {{code}}, type: typeof({{&dataType}}), description: "{{message}}")]{{/dataType}}{{^dataType}}{{/dataType}}{{/responses}}{{/useSwashbuckle}}{{^useSwashbuckle}}{{#responses}}{{#dataType}} [ProducesResponseType(statusCode: {{code}}, type: typeof({{&dataType}}))]{{/dataType}}{{^dataType}}{{/dataType}}{{/responses}}{{/useSwashbuckle}} - public {{operationModifier}} {{#operationResultTask}}{{#operationIsAsync}}async {{/operationIsAsync}}Task<{{/operationResultTask}}IActionResult{{#operationResultTask}}>{{/operationResultTask}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{^generateBody}};{{/generateBody}} + public {{operationModifier}} {{#operationResultTask}}{{#operationIsAsync}}async {{/operationIsAsync}}Task<{{/operationResultTask}}IActionResult{{#operationResultTask}}>{{/operationResultTask}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}{{^isCookieParam}}, {{/isCookieParam}}{{/hasMore}}{{/allParams}}){{^generateBody}};{{/generateBody}} {{#generateBody}} - { {{#responses}} + { + {{#cookieParams}} + var {{paramName}} = Request.Cookies["{{paramName}}"]; + {{/cookieParams}} + +{{#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}})); @@ -50,7 +55,8 @@ namespace {{apiPackage}} {{^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}} +{{/dataType}} +{{/responses}} {{#returnType}} string exampleJson = null; {{#examples}}