Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions scripts/testCodeGenWithClass.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import * as Writer from "./writer/Class";

const main = () => {
Writer.generateTypedefCodeOnly("test/api.test.domain/index.yml", "test/code/class/typedef-only/api.test.domain.ts", true);
Writer.generateTypedefCodeOnly("test/infer.domain/index.yml", "test/code/class/typedef-only/infer.domain.ts", false);
Writer.generateTypedefCodeOnly("test/json.properties/index.yml", "test/code/class/typedef-only/json.properties.ts", false);

Writer.generateTemplateCodeOnly("test/api.test.domain/index.yml", "test/code/class/template-only/api.test.domain.ts", true, { sync: false });
Writer.generateTemplateCodeOnly("test/api.test.domain/index.yml", "test/code/class/template-only/sync-api.test.domain.ts", true, {
sync: true,
});
Writer.generateTemplateCodeOnly("test/infer.domain/index.yml", "test/code/class/template-only/infer.domain.ts", false, { sync: true });

Writer.generateTypedefWithTemplateCode("test/api.v2.domain/index.yml", "test/code/class/typedef-with-template/api.v2.domain.ts", false, {
sync: false,
});
Writer.generateTypedefWithTemplateCode("test/api.test.domain/index.yml", "test/code/class/typedef-with-template/api.test.domain.ts", true, {
sync: false,
});
Writer.generateTypedefWithTemplateCode(
"test/api.test.domain/index.yml",
"test/code/class/typedef-with-template/sync-api.test.domain.ts",
true,
{
sync: true,
},
);
Writer.generateTypedefWithTemplateCode("test/infer.domain/index.yml", "test/code/class/typedef-with-template/infer.domain.ts", false, {
sync: false,
});

Writer.generateTypedefWithTemplateCode("test/ref.access/index.yml", "test/code/class/typedef-with-template/ref-access.ts", false, {
sync: false,
});
// Writer.generateTypedefCodeOnly("test/api.test.domain/index.yml", "test/code/class/typedef-only/api.test.domain.ts", true);
// Writer.generateTypedefCodeOnly("test/infer.domain/index.yml", "test/code/class/typedef-only/infer.domain.ts", false);
// Writer.generateTypedefCodeOnly("test/json.properties/index.yml", "test/code/class/typedef-only/json.properties.ts", false);

// Writer.generateTemplateCodeOnly("test/api.test.domain/index.yml", "test/code/class/template-only/api.test.domain.ts", true, { sync: false });
// Writer.generateTemplateCodeOnly("test/api.test.domain/index.yml", "test/code/class/template-only/sync-api.test.domain.ts", true, {
// sync: true,
// });
// Writer.generateTemplateCodeOnly("test/infer.domain/index.yml", "test/code/class/template-only/infer.domain.ts", false, { sync: true });

// Writer.generateTypedefWithTemplateCode("test/api.v2.domain/index.yml", "test/code/class/typedef-with-template/api.v2.domain.ts", false, {
// sync: false,
// });
// Writer.generateTypedefWithTemplateCode("test/api.test.domain/index.yml", "test/code/class/typedef-with-template/api.test.domain.ts", true, {
// sync: false,
// });
// Writer.generateTypedefWithTemplateCode(
// "test/api.test.domain/index.yml",
// "test/code/class/typedef-with-template/sync-api.test.domain.ts",
// true,
// {
// sync: true,
// },
// );
// Writer.generateTypedefWithTemplateCode("test/infer.domain/index.yml", "test/code/class/typedef-with-template/infer.domain.ts", false, {
// sync: false,
// });

// Writer.generateTypedefWithTemplateCode("test/ref.access/index.yml", "test/code/class/typedef-with-template/ref-access.ts", false, {
// sync: false,
// });
Writer.generateTypedefWithTemplateCode("test/remote.ref.access/v1.yml", "test/code/class/typedef-with-template/remote-ref-access.ts", false, {
sync: false,
});
Writer.generateTypedefWithTemplateCode("test/kubernetes/openapi-v1.18.5.json", "test/code/class/kubernetes/client-v1.18.5.ts", false, {
sync: false,
});
Writer.generateTypedefWithTemplateCode("test/argo-rollout/index.json", "test/code/class/argo-rollout/client.ts", false, {
sync: false,
});
Writer.generateTypedefWithTemplateCode("test/unknown.schema.domain/index.yml", "test/code/class/unknown.schema.domain/client.ts", false, {
sync: false,
});
// Writer.generateTypedefWithTemplateCode("test/kubernetes/openapi-v1.18.5.json", "test/code/class/kubernetes/client-v1.18.5.ts", false, {
// sync: false,
// });
// Writer.generateTypedefWithTemplateCode("test/argo-rollout/index.json", "test/code/class/argo-rollout/client.ts", false, {
// sync: false,
// });
// Writer.generateTypedefWithTemplateCode("test/unknown.schema.domain/index.yml", "test/code/class/unknown.schema.domain/client.ts", false, {
// sync: false,
// });

Writer.generateSplitCode("test/api.test.domain/index.yml", "test/code/class/split");
Writer.generateSplitCode("test/multi-type.test.domain/index.yml", "test/code/class/mulit-type-test.domain");
// Writer.generateSplitCode("test/api.test.domain/index.yml", "test/code/class/split");
// Writer.generateSplitCode("test/multi-type.test.domain/index.yml", "test/code/class/mulit-type-test.domain");

Writer.generateParameter("test/api.test.domain/index.yml", "test/code/class/parameter/api.test.domain.json");
Writer.generateParameter("test/infer.domain/index.yml", "test/code/class/parameter/infer.domain.json");
// Writer.generateParameter("test/api.test.domain/index.yml", "test/code/class/parameter/api.test.domain.json");
// Writer.generateParameter("test/infer.domain/index.yml", "test/code/class/parameter/infer.domain.json");

Writer.generateFormatTypeCode("test/format.domain/index.yml", "test/code/class/format.domain/code.ts");
// Writer.generateFormatTypeCode("test/format.domain/index.yml", "test/code/class/format.domain/code.ts");
};

main();
4 changes: 4 additions & 0 deletions src/internal/OpenApiTools/TypeNodeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ export const create = (
remainPathArray: string[] = [],
): OpenApi.Schema | OpenApi.Reference | OpenApi.JSONSchemaDefinition => {
const schema = DotProp.get<OpenApi.Schema>(rootSchema, pathArray.join("."));
console.log(JSON.stringify({ pathArray, remainPathArray }));
if (!schema) {
if (pathArray.length === 0) {
throw new Error("Not found");
}
return findSchemaByPathArray(pathArray.slice(0, pathArray.length - 1), [pathArray[pathArray.length - 1], ...remainPathArray]);
}
if (Guard.isReference(schema)) {
Expand Down
12 changes: 8 additions & 4 deletions test/remote.ref.access/v0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ tags:

components:
schemas:
BookID:
type: string
format: uuid
Book:
type: object
required:
- id
- metadata
properties:
id:
$ref: "#/components/schemas/BookID"
author:
type: object
properties:
Expand Down Expand Up @@ -56,8 +62,7 @@ paths:
required: true
description: Book ID
schema:
type: string
format: uuid
$ref: "#/components/schemas/BookID"
get:
operationId: getBook
responses:
Expand All @@ -74,8 +79,7 @@ paths:
required: true
description: Book ID
schema:
type: string
format: uuid
$ref: "#/components/schemas/BookID"
get:
operationId: getDescription
responses:
Expand Down
6 changes: 2 additions & 4 deletions test/remote.ref.access/v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ paths:
required: true
description: Book ID
schema:
type: string
format: uuid
$ref: "v0.yml#/components/schemas/BookID"
get:
operationId: getBook
responses:
Expand All @@ -50,8 +49,7 @@ paths:
required: true
description: Book ID
schema:
type: string
format: uuid
$ref: "v0.yml#/components/schemas/BookID"
get:
operationId: getDescription
responses:
Expand Down