@team-supercharge/oasg 16.6.0-temp-feature-remove-deprecated-file-mapping-config-spring-kotlin-72aca490 → 16.6.0-temp-feature-nestjs-response-object-267b5137
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/README.md
CHANGED
@@ -926,7 +926,7 @@ describe('Auth', function () {
|
|
926
926
|
| repository | URL of the NPM package registry | Y | - |
|
927
927
|
|
928
928
|
**Authorisation**<br>
|
929
|
-
The package generates an AuthGuard and applies to endpoints
|
929
|
+
The package generates an AuthGuard and applies it to endpoints where a security scheme is defined.
|
930
930
|
|
931
931
|
AuthGuard usage:
|
932
932
|
Implement the `AuthServiceInterface`, which will receive a validation request for each security scheme added to the checked endpoint and define the validation per scheme.
|
@@ -953,7 +953,7 @@ Future improvements:
|
|
953
953
|
- no multidimensional array validation in DTOs
|
954
954
|
|
955
955
|
**Validation availability:**
|
956
|
-
<br> _List is not comprehensive, missing items are definitely not
|
956
|
+
<br> _List is not comprehensive, missing items are definitely not supported currently_
|
957
957
|
|
958
958
|
Validations in General:
|
959
959
|
| Validation | DTO | Query | Header | Path |
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@team-supercharge/oasg",
|
3
|
-
"version": "16.6.0-temp-feature-
|
3
|
+
"version": "16.6.0-temp-feature-nestjs-response-object-267b5137",
|
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",
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
import { Get, Post, Put, Delete, Patch, Options, Head } from '@nestjs/common';
|
6
6
|
import { Query, Param, Headers, Body } from '@nestjs/common';
|
7
|
-
import { HttpCode, Request } from '@nestjs/common';
|
7
|
+
import { HttpCode, Request, Response } from '@nestjs/common';
|
8
8
|
import { UseInterceptors, UseGuards, UploadedFile, StreamableFile } from '@nestjs/common';
|
9
9
|
import { FileInterceptor } from '@nestjs/platform-express';
|
10
10
|
|
@@ -51,11 +51,11 @@ export abstract class {{classname}} {
|
|
51
51
|
//// @{{httpMethod}}('{{path}}'){{#isMultipart}}
|
52
52
|
@UseInterceptors(FileInterceptor({{#formParams}}{{#isFile}}'{{paramName}}'{{/isFile}}{{/formParams}})){{/isMultipart}}
|
53
53
|
@HttpCode({{#responses.0}}{{code}}{{/responses.0}})
|
54
|
-
private _{{nickname}}(@Request() req{{#allParams}}{{^isBodyParam}}, {{#isQueryParam}}@Query({{/isQueryParam}}{{#isPathParam}}@Param({{/isPathParam}}{{#isHeaderParam}}@Headers({{/isHeaderParam}}{{#isFormParam}}{{^isFile}}@Body({{/isFile}}{{#isFile}}@UploadedFile({{/isFile}}{{/isFormParam}}'{{paramName}}'{{#required}}{{#isHeaderParam}}{{/isHeaderParam}}{{^isHeaderParam}}, RequiredPipe{{/isHeaderParam}}{{/required}}{{#isArray}}, new ApiParseArrayPipe({ optional: true{{#items}}{{#isNumeric}}, items: Number{{/isNumeric}}{{#isBoolean}}, items: Boolean{{/isBoolean}}{{/items}} }){{/isArray}}{{#isNumber}}, OptionalParseFloatPipe{{/isNumber}}{{#isFloat}}, OptionalParseFloatPipe{{/isFloat}}{{#isDouble}}, OptionalParseFloatPipe{{/isDouble}}{{#isInteger}}, OptionalParseIntPipe{{/isInteger}}{{#isLong}}, OptionalParseIntPipe{{/isLong}}{{#isBoolean}}, OptionalParseBoolPipe{{/isBoolean}}{{#allowableValues}}{{^enumVars.empty}}, new OptionalParseEnumPipe({{{dataType}}}){{/enumVars.empty}}{{/allowableValues}}) {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{/isBodyParam}}{{/allParams}}{{#bodyParam}}, @Body(new ApiValidationPipe({ whitelist: true, forbidNonWhitelisted: true })) requestBody{{^required}}?{{/required}}: {{{dataType}}}{{/bodyParam}}): Promise<{{#returnType}}{{#isResponseFile}}StreamableFile{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
55
|
-
return this.{{nickname}}({{#allParams.0}}{ params: { {{#allParams}}{{^isBodyParam}}{{^-first}}, {{/-first}}{{paramName}}{{/isBodyParam}}{{/allParams}} }{{#bodyParam}}, body: requestBody{{/bodyParam}} }, {{/allParams.0}}req);
|
54
|
+
private _{{nickname}}(@Request() req: unknown, @Response() res: unknown{{#allParams}}{{^isBodyParam}}, {{#isQueryParam}}@Query({{/isQueryParam}}{{#isPathParam}}@Param({{/isPathParam}}{{#isHeaderParam}}@Headers({{/isHeaderParam}}{{#isFormParam}}{{^isFile}}@Body({{/isFile}}{{#isFile}}@UploadedFile({{/isFile}}{{/isFormParam}}'{{paramName}}'{{#required}}{{#isHeaderParam}}{{/isHeaderParam}}{{^isHeaderParam}}, RequiredPipe{{/isHeaderParam}}{{/required}}{{#isArray}}, new ApiParseArrayPipe({ optional: true{{#items}}{{#isNumeric}}, items: Number{{/isNumeric}}{{#isBoolean}}, items: Boolean{{/isBoolean}}{{/items}} }){{/isArray}}{{#isNumber}}, OptionalParseFloatPipe{{/isNumber}}{{#isFloat}}, OptionalParseFloatPipe{{/isFloat}}{{#isDouble}}, OptionalParseFloatPipe{{/isDouble}}{{#isInteger}}, OptionalParseIntPipe{{/isInteger}}{{#isLong}}, OptionalParseIntPipe{{/isLong}}{{#isBoolean}}, OptionalParseBoolPipe{{/isBoolean}}{{#allowableValues}}{{^enumVars.empty}}, new OptionalParseEnumPipe({{{dataType}}}){{/enumVars.empty}}{{/allowableValues}}) {{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{/isBodyParam}}{{/allParams}}{{#bodyParam}}, @Body(new ApiValidationPipe({ whitelist: true, forbidNonWhitelisted: true })) requestBody{{^required}}?{{/required}}: {{{dataType}}}{{/bodyParam}}): Promise<{{#returnType}}{{#isResponseFile}}StreamableFile{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
55
|
+
return this.{{nickname}}({{#allParams.0}}{ params: { {{#allParams}}{{^isBodyParam}}{{^-first}}, {{/-first}}{{paramName}}{{/isBodyParam}}{{/allParams}} }{{#bodyParam}}, body: requestBody{{/bodyParam}} }, {{/allParams.0}}req, res);
|
56
56
|
}
|
57
57
|
|
58
|
-
abstract {{nickname}}({{#allParams.0}}context: {{operationIdCamelCase}}Context, {{/allParams.0}}req
|
58
|
+
abstract {{nickname}}({{#allParams.0}}context: {{operationIdCamelCase}}Context, {{/allParams.0}}req?: unknown, res?: unknown): Promise<{{#returnType}}{{#isResponseFile}}StreamableFile{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}void{{/returnType}}>;
|
59
59
|
|
60
60
|
{{/operation}}
|
61
61
|
// ||||||||||
|
@@ -10,7 +10,11 @@ export const IsValidISO8601Date = () => {
|
|
10
10
|
options: {},
|
11
11
|
validator: {
|
12
12
|
validate(value: string) {
|
13
|
-
const [year, month, day] = value.split("-").map(Number)
|
13
|
+
const [year, month, day] = value.split("-").map(Number) as [
|
14
|
+
number,
|
15
|
+
number,
|
16
|
+
number
|
17
|
+
];
|
14
18
|
const date = new Date(year, month - 1, day);
|
15
19
|
|
16
20
|
// Check if the date components are valid
|
@@ -7,7 +7,7 @@
|
|
7
7
|
"skipDefaultInterface": true,
|
8
8
|
"useTags": true,
|
9
9
|
"hideGenerationTimestamp": true,
|
10
|
-
"enumPropertyNaming": "
|
10
|
+
"enumPropertyNaming": "UPPERCASE",
|
11
11
|
"removeEnumValuePrefix": false,
|
12
12
|
"documentationProvider": "none",
|
13
13
|
"annotationLibrary": "none",
|
@@ -11,11 +11,13 @@
|
|
11
11
|
"requestMappingMode": "api_interface",
|
12
12
|
"typeMappings": {
|
13
13
|
"DateTime": "java.time.Instant",
|
14
|
-
"OffsetDateTime": "java.time.Instant"
|
14
|
+
"OffsetDateTime": "java.time.Instant",
|
15
|
+
"org.springframework.core.io.Resource": "org.springframework.web.multipart.MultipartFile"
|
15
16
|
},
|
16
17
|
"importMappings": {
|
17
18
|
"DateTime": "java.time.Instant",
|
18
|
-
"java.time.OffsetDateTime": "java.time.Instant"
|
19
|
+
"java.time.OffsetDateTime": "java.time.Instant",
|
20
|
+
"org.springframework.core.io.Resource": "org.springframework.web.multipart.MultipartFile"
|
19
21
|
},
|
20
22
|
"inlineSchemaOptions": {
|
21
23
|
"ARRAY_ITEM_SUFFIX": "",
|