@team-supercharge/oasg 16.4.0-feature-aspdotnetcore-generator-c0fb9acc.0 → 16.4.0-feature-aspdotnetcore-generator-df47ebf4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "16.4.0-feature-aspdotnetcore-generator-c0fb9acc.0",
3
+ "version": "16.4.0-feature-aspdotnetcore-generator-df47ebf4.0",
4
4
  "description": "Node-based tool to lint OpenAPI documents and generate clients, servers and documentation from them",
5
5
  "author": "Supercharge",
6
6
  "license": "MIT",
@@ -16,6 +16,6 @@ dotnet build -c Release
16
16
  dotnet pack -c Release -p:Version=$version -p:IsPackable=true
17
17
 
18
18
  # publish
19
- dotnet nuget push "src/**/bin/Release/*.nupkg" --source $sourceUrl -k ${$apiKey:-CI_JOB_TOKEN}
19
+ dotnet nuget push "src/**/bin/Release/*.nupkg" --source $sourceUrl -k ${apiKey:-$CI_JOB_TOKEN}
20
20
 
21
21
  cd ../..
@@ -0,0 +1,95 @@
1
+ {{>partial_header}}
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using System.ComponentModel.DataAnnotations;
5
+ {{#operationResultTask}}
6
+ using System.Threading;
7
+ using System.Threading.Tasks;
8
+ {{/operationResultTask}}
9
+ using Microsoft.AspNetCore.Authorization;
10
+ using Microsoft.AspNetCore.Mvc;
11
+ using Microsoft.AspNetCore.Http;
12
+ {{#useSwashbuckle}}
13
+ using Swashbuckle.AspNetCore.Annotations;
14
+ using Swashbuckle.AspNetCore.SwaggerGen;
15
+ {{/useSwashbuckle}}
16
+ {{^isLibrary}}
17
+ {{#useNewtonsoft}}
18
+ using Newtonsoft.Json;
19
+ {{/useNewtonsoft}}
20
+ {{^useNewtonsoft}}
21
+ using System.Text.Json;
22
+ {{/useNewtonsoft}}
23
+ {{/isLibrary}}
24
+ using {{packageName}}.Attributes;
25
+ using {{modelPackage}};
26
+
27
+ namespace {{apiPackage}}
28
+ { {{#operations}}
29
+ /// <summary>
30
+ /// {{description}}
31
+ /// </summary>{{#description}}
32
+ [Description("{{.}}")]{{/description}}
33
+ [ApiController]
34
+ public {{#classModifier}}{{.}} {{/classModifier}}class {{classname}}Controller : ControllerBase
35
+ { {{#operation}}
36
+ /// <summary>
37
+ /// {{summary}}
38
+ /// </summary>{{#notes}}
39
+ /// <remarks>{{.}}</remarks>{{/notes}}{{#allParams}}
40
+ /// <param name="{{paramName}}">{{description}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>{{/allParams}}{{#operationResultTask}}{{#operationIsAsync}}
41
+ /// <param name="cancellationToken">The cancellation token to cancel the operation.</param>{{/operationIsAsync}}{{/operationResultTask}}{{#responses}}
42
+ /// <response code="{{code}}">{{message}}</response>{{/responses}}
43
+ [{{httpMethod}}]
44
+ [Route("{{{basePathWithoutHost}}}{{{path}}}")]
45
+ {{#authMethods}}
46
+ {{#isApiKey}}
47
+ [Authorize(Policy = "{{name}}")]
48
+ {{/isApiKey}}
49
+ {{#isBasicBearer}}
50
+ [Authorize{{#scopes}}{{#-first}}(Roles = "{{/-first}}{{scope}}{{^-last}},{{/-last}}{{#-last}}"){{/-last}}{{/scopes}}]
51
+ {{/isBasicBearer}}
52
+ {{/authMethods}}
53
+ {{#vendorExtensions.x-aspnetcore-consumes}}
54
+ [Consumes({{&vendorExtensions.x-aspnetcore-consumes}})]
55
+ {{/vendorExtensions.x-aspnetcore-consumes}}
56
+ [ValidateModelState]{{#useSwashbuckle}}
57
+ [SwaggerOperation("{{operationId}}")]{{#responses}}{{#dataType}}
58
+ [SwaggerResponse(statusCode: {{code}}, type: typeof({{&dataType}}), description: "{{message}}")]{{/dataType}}{{/responses}}{{/useSwashbuckle}}{{^useSwashbuckle}}{{#responses}}{{#dataType}}
59
+ [ProducesResponseType(statusCode: {{code}}, type: typeof({{&dataType}}))]{{/dataType}}{{/responses}}{{/useSwashbuckle}}
60
+ {{#isDeprecated}}
61
+ [Obsolete]
62
+ {{/isDeprecated}}
63
+ public {{operationModifier}} {{#operationResultTask}}{{#operationIsAsync}}async {{/operationIsAsync}}Task<{{/operationResultTask}}{{#responses}}{{#dataType}}ActionResult<{{&dataType}}>{{/dataType}}{{^dataType}}IActionResult{{/dataType}}{{/responses}}{{#operationResultTask}}>{{/operationResultTask}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{^-last}}{{^isCookieParam}}, {{/isCookieParam}}{{/-last}}{{#-last}}{{#operationResultTask}}{{#operationIsAsync}}, {{/operationIsAsync}}{{/operationResultTask}}{{/-last}}{{/allParams}}{{#operationResultTask}}{{#operationIsAsync}}CancellationToken cancellationToken{{/operationIsAsync}}{{/operationResultTask}}){{^generateBody}};{{/generateBody}}
64
+ {{#generateBody}}
65
+ {
66
+ {{#cookieParams}}
67
+ var {{paramName}} = Request.Cookies["{{paramName}}"];
68
+ {{/cookieParams}}
69
+
70
+ {{#responses}}
71
+ {{#dataType}}
72
+ //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
73
+ // return StatusCode({{code}}, default({{&dataType}}));
74
+ {{/dataType}}
75
+ {{^dataType}}
76
+ //TODO: Uncomment the next line to return response {{code}} or use other options such as return this.NotFound(), return this.BadRequest(..), ...
77
+ // return StatusCode({{code}});
78
+ {{/dataType}}
79
+ {{/responses}}
80
+ {{#returnType}}
81
+ string exampleJson = null;
82
+ {{#examples}}
83
+ exampleJson = "{{{example}}}";
84
+ {{/examples}}
85
+ {{#isListCollection}}{{>listReturn}}{{/isListCollection}}{{^isListCollection}}{{#isMap}}{{>mapReturn}}{{/isMap}}{{^isMap}}{{>objectReturn}}{{/isMap}}{{/isListCollection}}
86
+ {{!TODO: defaultResponse, examples, auth, consumes, produces, nickname, externalDocs, imports, security}}
87
+ //TODO: Change the data returned
88
+ return {{#operationResultTask}}{{#operationIsAsync}}await {{/operationIsAsync}}Task.FromResult<IActionResult>({{/operationResultTask}}new ObjectResult(example){{#operationResultTask}}){{/operationResultTask}};{{/returnType}}{{^returnType}}
89
+ throw new NotImplementedException();{{/returnType}}
90
+ }
91
+ {{/generateBody}}
92
+ {{/operation}}
93
+ }
94
+ {{/operations}}
95
+ }