@team-supercharge/oasg 15.0.0 → 15.1.1

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
@@ -122,7 +122,7 @@ The table below gives an overview of the changes (breaking, non-breaking, bug fi
122
122
  | `ios` |➖ |➖ |💥 |🐛 |➖ |➖ |➖ |✨ |➖ |💥 |➖ |➖ |✨ |🆕 |
123
123
  | `kmp` |➖ |🆕 |
124
124
  | `python` |➖ |🐛 |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
125
- | `react` |➖ |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
125
+ | `react` |🐛 |➖ |💥 |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |➖ |🆕 |
126
126
  | **Server Targets** | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
127
127
  | `nestjs` |💥 |➖ |💥 |✨ |➖ |➖ |🐛 |➖ |➖ |✨ |🆕 |
128
128
  | `python-fastapi` |➖ |🆕 |
@@ -927,7 +927,7 @@ Validations from OpenAPI spec:
927
927
  | isDouble | IsNumber | ✅ | ✅ | ✅ | ✅ | |
928
928
  | isEnum | IsEnum | ✅ | ✅ | ✅ | ✅ | |
929
929
  | isArray | IsArray | ✅ | ✅ | ✅ | ✅ | |
930
- | isDate | | | | | | `pattern`, `isDateTime` |
930
+ | isDate | IsValidISO8601Date | | | | | |
931
931
  | isDateTime | IsISO8601 | ✅ | ✅ | ✅ | ✅ | |
932
932
  | **String** | | | | | | |
933
933
  | pattern | Matches | ✅ | ✅ | ✅ | ✅ | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-supercharge/oasg",
3
- "version": "15.0.0",
3
+ "version": "15.1.1",
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",
@@ -37,6 +37,9 @@
37
37
  },
38
38
  "remove-empty-param-objects-from-context.js": {
39
39
  "templateType": "SupportingFiles"
40
+ },
41
+ "is-valid-iso8601-date.validator.ts": {
42
+ "templateType": "SupportingFiles"
40
43
  }
41
44
  },
42
45
  "typeMappings": {
@@ -0,0 +1,31 @@
1
+ import { registerDecorator, buildMessage } from "class-validator";
2
+
3
+ export const IsValidISO8601Date = () => {
4
+ return (object: Object, propertyName: string) => {
5
+ registerDecorator({
6
+ name: "isValidISO8601Date",
7
+ target: object.constructor,
8
+ propertyName: propertyName,
9
+ constraints: [],
10
+ options: {},
11
+ validator: {
12
+ validate(value: string) {
13
+ const [year, month, day] = value.split("-").map(Number);
14
+ const date = new Date(year, month - 1, day);
15
+
16
+ // Check if the date components are valid
17
+ return (
18
+ date.getFullYear() === year &&
19
+ date.getMonth() === month - 1 &&
20
+ date.getDate() === day
21
+ );
22
+ },
23
+ defaultMessage: buildMessage(
24
+ (eachPrefix) =>
25
+ eachPrefix +
26
+ "$property must be a valid ISO 8601 date string (YYYY-mm-DD format)"
27
+ ),
28
+ },
29
+ });
30
+ };
31
+ };
@@ -5,6 +5,7 @@ import { IsString, IsNumber, IsBoolean, IsEnum, IsArray, ValidateNested } from '
5
5
  import { Max, Min, IsInt } from 'class-validator';
6
6
  import { Matches, IsEmail, IsUUID } from 'class-validator';
7
7
  import { IsISO8601 } from 'class-validator';
8
+ import { IsValidISO8601Date } from '../is-valid-iso8601-date.validator';
8
9
 
9
10
  export class {{classname}}{{#allParents}}{{#-first}} extends {{/-first}}{{{.}}}{{^-last}}, {{/-last}}{{/allParents}} { {{>modelGenericAdditionalProperties}}
10
11
  {{#vars}}
@@ -19,7 +20,10 @@ export class {{classname}}{{#allParents}}{{#-first}} extends {{/-first}}{{{.}}}{
19
20
  @IsEmail(){{/isEmail}}{{#isUuid}}
20
21
  @IsUUID(){{/isUuid}}{{/isString}}{{#isDateTime}}
21
22
  @IsString()
22
- @IsISO8601({ strict: true, strictSeparator: true }){{/isDateTime}}{{#isInteger}}
23
+ @IsISO8601({ strict: true, strictSeparator: true }){{/isDateTime}}{{#isDate}}
24
+ @IsString()
25
+ @IsISO8601()
26
+ @IsValidISO8601Date(){{/isDate}}{{#isInteger}}
23
27
  @IsInt(){{/isInteger}}{{#isLong}}
24
28
  @IsInt(){{/isLong}}{{#isShort}}
25
29
  @IsInt(){{/isShort}}{{#isNumber}}
@@ -45,7 +45,7 @@ export type {{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}P
45
45
  {{/isDeprecated}}
46
46
  */
47
47
  export const use{{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Mutation = <TContext = unknown>(
48
- { onSuccess, ...options }: Omit<UseMutationOptions<{{{returnType}}}{{^returnType}}void{{/returnType}}, Error, {{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Parameters, TContext>, 'mutationFn'> = {}
48
+ options: Omit<UseMutationOptions<{{{returnType}}}{{^returnType}}void{{/returnType}}, Error, {{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Parameters, TContext>, 'mutationFn'> = {}
49
49
  ): UseMutationResult<{{{returnType}}}{{^returnType}}void{{/returnType}}, Error, {{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Parameters, TContext> => {
50
50
  const api = useApi({{classname}});
51
51
  return useMutation<{{{returnType}}}{{^returnType}}void{{/returnType}}, Error, {{classname}}{{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Parameters, TContext>({