mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 14:33:18 +02:00
Merge main into proxy branch (formatting and docs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { convertOpenApi } from '../src';
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { describe, expect, test } from "vite-plus/test";
|
||||
import { convertOpenApi } from "../src";
|
||||
|
||||
describe('importer-openapi', () => {
|
||||
const p = path.join(__dirname, 'fixtures');
|
||||
describe("importer-openapi", () => {
|
||||
const p = path.join(__dirname, "fixtures");
|
||||
const fixtures = fs.readdirSync(p);
|
||||
|
||||
test('Maps operation description to request description', async () => {
|
||||
test("Maps operation description to request description", async () => {
|
||||
const imported = await convertOpenApi(
|
||||
JSON.stringify({
|
||||
openapi: '3.0.0',
|
||||
info: { title: 'Description Test', version: '1.0.0' },
|
||||
openapi: "3.0.0",
|
||||
info: { title: "Description Test", version: "1.0.0" },
|
||||
paths: {
|
||||
'/klanten': {
|
||||
"/klanten": {
|
||||
get: {
|
||||
description: 'Lijst van klanten',
|
||||
responses: { '200': { description: 'ok' } },
|
||||
description: "Lijst van klanten",
|
||||
responses: { "200": { description: "ok" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -25,24 +25,24 @@ describe('importer-openapi', () => {
|
||||
|
||||
expect(imported?.resources.httpRequests).toEqual([
|
||||
expect.objectContaining({
|
||||
description: 'Lijst van klanten',
|
||||
description: "Lijst van klanten",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test('Skips invalid file', async () => {
|
||||
const imported = await convertOpenApi('{}');
|
||||
test("Skips invalid file", async () => {
|
||||
const imported = await convertOpenApi("{}");
|
||||
expect(imported).toBeUndefined();
|
||||
});
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
test(`Imports ${fixture}`, async () => {
|
||||
const contents = fs.readFileSync(path.join(p, fixture), 'utf-8');
|
||||
const contents = fs.readFileSync(path.join(p, fixture), "utf-8");
|
||||
const imported = await convertOpenApi(contents);
|
||||
expect(imported?.resources.workspaces).toEqual([
|
||||
expect.objectContaining({
|
||||
name: 'Swagger Petstore - OpenAPI 3.0',
|
||||
description: expect.stringContaining('This is a sample Pet Store Server'),
|
||||
name: "Swagger Petstore - OpenAPI 3.0",
|
||||
description: expect.stringContaining("This is a sample Pet Store Server"),
|
||||
}),
|
||||
]);
|
||||
expect(imported?.resources.httpRequests.length).toBe(19);
|
||||
|
||||
Reference in New Issue
Block a user