Skip to content

Commit 7e0ce78

Browse files
committed
Fix the braindead way of exporting schemas
1 parent f0eb4ec commit 7e0ce78

24 files changed

+355
-265
lines changed

dist/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@ const getModel = (openApi, definition, isDefinition = false, name = '') => {
16121612
enum: [],
16131613
enums: [],
16141614
properties: [],
1615+
rawSchema: JSON.stringify(definition, null, 2),
16151616
};
16161617
if (definition.$ref) {
16171618
const definitionRef = getType(definition.$ref);
@@ -4804,7 +4805,7 @@ var templateExportModel = {"1":function(container,depth0,helpers,partials,data)
48044805
},"usePartial":true,"useData":true};
48054806

48064807
var templateExportSchema = {"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
4807-
var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
4808+
var stack1, alias1=container.strict, alias2=container.lambda, lookupProperty = container.lookupProperty || function(parent, propertyName) {
48084809
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
48094810
return parent[propertyName];
48104811
}
@@ -4813,9 +4814,9 @@ var templateExportSchema = {"compiler":[8,">= 4.3.0"],"main":function(container,
48134814

48144815
return ((stack1 = container.invokePartial(lookupProperty(partials,"header"),depth0,{"name":"header","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
48154816
+ "\nexport const $"
4816-
+ ((stack1 = container.lambda(container.strict(depth0, "name", {"start":{"line":3,"column":17},"end":{"line":3,"column":21}} ), depth0)) != null ? stack1 : "")
4817+
+ ((stack1 = alias2(alias1(depth0, "name", {"start":{"line":3,"column":17},"end":{"line":3,"column":21}} ), depth0)) != null ? stack1 : "")
48174818
+ " = "
4818-
+ ((stack1 = container.invokePartial(lookupProperty(partials,"schema"),depth0,{"name":"schema","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
4819+
+ ((stack1 = alias2(alias1(depth0, "rawSchema", {"start":{"line":3,"column":29},"end":{"line":3,"column":38}} ), depth0)) != null ? stack1 : "")
48194820
+ " as const;";
48204821
},"usePartial":true,"useData":true};
48214822

src/client/interfaces/Model.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export interface Model extends Schema {
1515
enum: Enum[];
1616
enums: Model[];
1717
properties: Model[];
18+
rawSchema?: string;
1819
}

src/openApi/v3/parser/getModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const getModel = (
4646
enum: [],
4747
enums: [],
4848
properties: [],
49+
rawSchema: JSON.stringify(definition, null, 2),
4950
};
5051

5152
if (definition.$ref) {

src/templates/exportSchema.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{{>header}}
22

3-
export const ${{{name}}} = {{>schema}} as const;
3+
export const ${{{name}}} = {{rawSchema}} as const;

tester/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type { MemberDefinition } from './models/MemberDefinition';
1515
export type { MemberPatch } from './models/MemberPatch';
1616
export type { SignedUrlResponse } from './models/SignedUrlResponse';
1717
export type { StampCard } from './models/StampCard';
18+
export type { StampCardAddStamps } from './models/StampCardAddStamps';
1819
export type { StampCardDefinition } from './models/StampCardDefinition';
1920
export type { StampCardType } from './models/StampCardType';
2021
export type { StampCardTypePatch } from './models/StampCardTypePatch';
@@ -28,6 +29,7 @@ export { $MemberDefinition } from './schemas/$MemberDefinition';
2829
export { $MemberPatch } from './schemas/$MemberPatch';
2930
export { $SignedUrlResponse } from './schemas/$SignedUrlResponse';
3031
export { $StampCard } from './schemas/$StampCard';
32+
export { $StampCardAddStamps } from './schemas/$StampCardAddStamps';
3133
export { $StampCardDefinition } from './schemas/$StampCardDefinition';
3234
export { $StampCardType } from './schemas/$StampCardType';
3335
export { $StampCardTypePatch } from './schemas/$StampCardTypePatch';

tester/models/StampCardAddStamps.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* generated using openapi-typescript-codegen -- do not edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
/**
6+
* StampCardAddStamps schema
7+
*/
8+
export type StampCardAddStamps = {
9+
stamps: number;
10+
};
11+

tester/models/StampCardType.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export type StampCardType = {
1313
foregroundColor: string;
1414
id?: string;
1515
labelColor: string;
16-
logoText: string;
17-
logoUrl: string;
16+
logoText?: string | null;
17+
logoUrl?: string | null;
1818
milestones: Array<{
1919
action?: {
2020
meta?: any;

tester/schemas/$HTTPError.ts

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,60 @@
33
/* tslint:disable */
44
/* eslint-disable */
55
export const $HTTPError = {
6-
description: `HTTPError schema`,
7-
properties: {
8-
detail: {
9-
type: 'string',
10-
description: `Human readable error message`,
11-
isNullable: true,
6+
"description": "HTTPError schema",
7+
"properties": {
8+
"detail": {
9+
"description": "Human readable error message",
10+
"nullable": true,
11+
"type": "string"
1212
},
13-
errors: {
14-
type: 'array',
15-
contains: {
16-
properties: {
17-
more: {
18-
type: 'dictionary',
19-
contains: {
20-
description: `Additional information about the error`,
21-
properties: {
22-
},
23-
isNullable: true,
13+
"errors": {
14+
"items": {
15+
"nullable": true,
16+
"properties": {
17+
"more": {
18+
"additionalProperties": {
19+
"description": "Additional information about the error",
20+
"nullable": true
2421
},
25-
isNullable: true,
22+
"description": "Additional information about the error",
23+
"nullable": true,
24+
"type": "object"
2625
},
27-
name: {
28-
type: 'string',
29-
description: `For example, name of the parameter that caused the error`,
30-
},
31-
reason: {
32-
type: 'string',
33-
description: `Human readable error message`,
26+
"name": {
27+
"description": "For example, name of the parameter that caused the error",
28+
"type": "string"
3429
},
30+
"reason": {
31+
"description": "Human readable error message",
32+
"type": "string"
33+
}
3534
},
36-
isNullable: true,
35+
"type": "object"
3736
},
38-
isNullable: true,
39-
},
40-
instance: {
41-
type: 'string',
42-
isNullable: true,
37+
"nullable": true,
38+
"type": "array"
4339
},
44-
status: {
45-
type: 'number',
46-
description: `HTTP status code`,
47-
isNullable: true,
40+
"instance": {
41+
"nullable": true,
42+
"type": "string"
4843
},
49-
title: {
50-
type: 'string',
51-
description: `Short title of the error`,
52-
isNullable: true,
44+
"status": {
45+
"description": "HTTP status code",
46+
"example": 403,
47+
"nullable": true,
48+
"type": "integer"
5349
},
54-
type: {
55-
type: 'string',
56-
description: `URL of the error type. Can be used to lookup the error in a documentation`,
57-
isNullable: true,
50+
"title": {
51+
"description": "Short title of the error",
52+
"nullable": true,
53+
"type": "string"
5854
},
55+
"type": {
56+
"description": "URL of the error type. Can be used to lookup the error in a documentation",
57+
"nullable": true,
58+
"type": "string"
59+
}
5960
},
61+
"type": "object"
6062
} as const;

tester/schemas/$Member.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,33 @@
33
/* tslint:disable */
44
/* eslint-disable */
55
export const $Member = {
6-
description: `Member schema`,
7-
properties: {
8-
authIdentifier: {
9-
type: 'string',
6+
"description": "Member schema",
7+
"properties": {
8+
"authIdentifier": {
9+
"type": "string"
1010
},
11-
createdAt: {
12-
type: 'string',
13-
format: 'date-time',
11+
"createdAt": {
12+
"format": "date-time",
13+
"type": "string"
1414
},
15-
deletedAt: {
16-
type: 'string',
17-
format: 'date-time',
15+
"deletedAt": {
16+
"format": "date-time",
17+
"type": "string"
1818
},
19-
firstName: {
20-
type: 'string',
19+
"firstName": {
20+
"type": "string"
2121
},
22-
id: {
23-
type: 'string',
24-
format: 'uuid',
22+
"id": {
23+
"format": "uuid",
24+
"type": "string"
2525
},
26-
lastName: {
27-
type: 'string',
28-
},
29-
updatedAt: {
30-
type: 'string',
31-
format: 'date-time',
26+
"lastName": {
27+
"type": "string"
3228
},
29+
"updatedAt": {
30+
"format": "date-time",
31+
"type": "string"
32+
}
3333
},
34+
"type": "object"
3435
} as const;

tester/schemas/$MemberDefinition.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
/* tslint:disable */
44
/* eslint-disable */
55
export const $MemberDefinition = {
6-
description: `MemberDefinition schema`,
7-
properties: {
8-
authIdentifier: {
9-
type: 'string',
6+
"description": "MemberDefinition schema",
7+
"properties": {
8+
"authIdentifier": {
9+
"type": "string"
1010
},
11-
firstName: {
12-
type: 'string',
13-
},
14-
lastName: {
15-
type: 'string',
11+
"firstName": {
12+
"type": "string"
1613
},
14+
"lastName": {
15+
"type": "string"
16+
}
1717
},
18+
"type": "object"
1819
} as const;

0 commit comments

Comments
 (0)