Skip to content

chore: add fixtures to OpenApi Parser v2 #2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 30, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class XFernGlobalHeadersConverterNode extends BaseOpenApiV3_1ConverterNod
context: this.context,
accessPath: this.accessPath,
pathId: this.pathId,
seenSchemas: new Set(),
}),
];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,12 @@ export class OperationObjectConverterNode extends BaseOpenApiV3_1ConverterNode<

this.requests =
this.input.requestBody != null
? new RequestBodyObjectConverterNode(
{
input: this.input.requestBody,
context: this.context,
accessPath: this.accessPath,
pathId: "requestBody",
},
this.path
)
? new RequestBodyObjectConverterNode({
input: this.input.requestBody,
context: this.context,
accessPath: this.accessPath,
pathId: "requestBody",
})
: undefined;

this.responses =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("ExampleObjectConverterNode", () => {
fields: {
file: { multipartType: "file" },
},
} as RequestMediaTypeObjectConverterNode,
} as unknown as RequestMediaTypeObjectConverterNode,
responseBody: undefined,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

expect(converter.multipartType).toBe("file");
Expand All @@ -38,6 +39,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

expect(converter.multipartType).toBe("files");
Expand All @@ -55,6 +57,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

expect(converter.multipartType).toBe("property");
Expand All @@ -80,6 +83,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

expect(converter.multipartType).toBe("file");
Expand All @@ -99,6 +103,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

expect(converter.multipartType).toBeUndefined();
Expand All @@ -118,6 +123,7 @@ describe("MultipartFormDataPropertySchemaConverterNode", () => {
context: mockContext,
accessPath: [],
pathId: "test",
seenSchemas: new Set(),
});

const result = converter.convert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"application/json",
undefined
undefined,
"test",
200,
[],
{}
);

expect(converter.contentType).toBe("application/json");
Expand All @@ -48,7 +52,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"application/octet-stream",
undefined
undefined,
"test",
200,
[],
{}
);

expect(converter.contentType).toBe("application/octet-stream");
Expand All @@ -73,7 +81,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"application/json",
"json"
"json",
"test",
200,
[],
{}
);

expect(converter.contentType).toBe("application/json");
Expand All @@ -92,7 +104,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"text/event-stream",
"sse"
"sse",
"test",
200,
[],
{}
);

const result = converter.convert();
Expand All @@ -110,7 +126,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"application/json",
undefined
undefined,
"test",
200,
[],
{}
);

expect(mockContext.errors.error).toHaveBeenCalledWith({
Expand Down Expand Up @@ -144,7 +164,11 @@ describe("ResponseMediaTypeObjectConverterNode", () => {
pathId: "test",
},
"application/json",
undefined
undefined,
"test",
200,
[],
{}
);

expect(converter.schema).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ describe("ResponseObjectConverterNode", () => {
},
};

const converter = new ResponseObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponseObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
200,
[],
{}
);

expect(converter.description).toBe("Success response");
expect(converter.responses).toBeDefined();
Expand All @@ -44,12 +50,18 @@ describe("ResponseObjectConverterNode", () => {
},
};

const converter = new ResponseObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponseObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
200,
[],
{}
);

expect(converter.headers).toBeDefined();
expect(converter.headers?.["X-Rate-Limit"]).toBeDefined();
Expand All @@ -74,12 +86,18 @@ describe("ResponseObjectConverterNode", () => {
},
};

const converter = new ResponseObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponseObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
200,
[],
{}
);

expect(converter.responses).toBeDefined();
expect(converter.responses?.length).toBe(1);
Expand All @@ -90,12 +108,18 @@ describe("ResponseObjectConverterNode", () => {
$ref: "#/components/responses/NonExistent",
};

new ResponseObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
new ResponseObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
200,
[],
{}
);

expect(mockContext.errors.error).toHaveBeenCalledWith({
message: "Undefined reference: #/components/responses/NonExistent",
Expand Down Expand Up @@ -124,12 +148,18 @@ describe("ResponseObjectConverterNode", () => {
},
};

const converter = new ResponseObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponseObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
200,
[],
{}
);

const shapes = converter.convert();
expect(shapes).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ describe("ResponsesObjectConverterNode", () => {
},
};

const converter = new ResponsesObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponsesObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
[],
{}
);

const result = converter.convert();
expect(result?.responses).toBeDefined();
Expand Down Expand Up @@ -60,7 +65,8 @@ describe("ResponsesObjectConverterNode", () => {
pathId: "test",
},
"testpath",
undefined
[],
{}
);

const result = converter.convert();
Expand Down Expand Up @@ -90,12 +96,17 @@ describe("ResponsesObjectConverterNode", () => {
},
};

const converter = new ResponsesObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponsesObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
[],
{}
);

const result = converter.convert();
expect(result?.responses[0]?.headers).toBeDefined();
Expand All @@ -118,12 +129,17 @@ describe("ResponsesObjectConverterNode", () => {
},
};

const converter = new ResponsesObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponsesObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
[],
{}
);

const result = converter.convert();
expect(result?.responses).toBeDefined();
Expand All @@ -132,12 +148,17 @@ describe("ResponsesObjectConverterNode", () => {
it("should handle empty responses", () => {
const input: OpenAPIV3_1.ResponsesObject = {};

const converter = new ResponsesObjectConverterNode({
input,
context: mockContext,
accessPath: [],
pathId: "test",
});
const converter = new ResponsesObjectConverterNode(
{
input,
context: mockContext,
accessPath: [],
pathId: "test",
},
"test",
[],
{}
);

const result = converter.convert();
expect(result?.responses).toEqual([]);
Expand Down
Loading