diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1ff743..29a1406 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 - name: Setup Deno uses: denoland/setup-deno@v2 with: diff --git a/deno.json b/deno.json index f007c60..58df013 100644 --- a/deno.json +++ b/deno.json @@ -15,7 +15,7 @@ "@deno/dnt": "jsr:@deno/dnt@^0.41.3", "@std/assert": "jsr:@std/assert@^1.0.6", "@std/expect": "jsr:@std/expect@^1.0.5", - "@std/testing": "jsr:@std/testing@1.0.4", + "@std/testing": "jsr:@std/testing@^1.0.4", "@std/text": "jsr:@std/text@^1.0.7", "@types/fs-extra": "npm:@types/fs-extra@^11.0.4", "@types/node": "npm:@types/node@^22.7.5", diff --git a/deno.lock b/deno.lock index 8fd8856..b82d366 100644 --- a/deno.lock +++ b/deno.lock @@ -27,11 +27,13 @@ "jsr:@std/path@^1.0.7": "1.0.8", "jsr:@std/path@^1.0.8": "1.0.8", "jsr:@std/path@~0.225.2": "0.225.2", - "jsr:@std/testing@1.0.4": "1.0.4", + "jsr:@std/testing@^1.0.4": "1.0.4", "jsr:@std/text@^1.0.7": "1.0.8", "jsr:@ts-morph/bootstrap@0.24": "0.24.0", "jsr:@ts-morph/common@0.24": "0.24.0", + "npm:@types/fs-extra@*": "11.0.4", "npm:@types/fs-extra@^11.0.4": "11.0.4", + "npm:@types/node@*": "22.5.4", "npm:@types/node@^22.7.5": "22.8.6", "npm:concurrently@^9.0.1": "9.0.1", "npm:fs-extra@^11.2.0": "11.2.0", @@ -362,7 +364,7 @@ "jsr:@deno/dnt@~0.41.3", "jsr:@std/assert@^1.0.6", "jsr:@std/expect@^1.0.5", - "jsr:@std/testing@1.0.4", + "jsr:@std/testing@^1.0.4", "jsr:@std/text@^1.0.7", "npm:@types/fs-extra@^11.0.4", "npm:@types/node@^22.7.5", diff --git a/packages/core/src/codegen/generator.ts b/packages/core/src/codegen/generator.ts index 6d6e0f9..e407b00 100644 --- a/packages/core/src/codegen/generator.ts +++ b/packages/core/src/codegen/generator.ts @@ -1,6 +1,6 @@ import { resolve } from 'node:path'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; import { OpenApiParser } from '../parse/parser.ts'; diff --git a/packages/core/src/parse/parser.ts b/packages/core/src/parse/parser.ts index 094627a..a2213d9 100644 --- a/packages/core/src/parse/parser.ts +++ b/packages/core/src/parse/parser.ts @@ -1,7 +1,7 @@ import path from 'node:path'; import { cwd } from 'node:process'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; import * as YAML from 'yaml'; diff --git a/packages/core/src/utils/asset-manager.ts b/packages/core/src/utils/asset-manager.ts index c7173a9..d2cf7c3 100644 --- a/packages/core/src/utils/asset-manager.ts +++ b/packages/core/src/utils/asset-manager.ts @@ -1,7 +1,7 @@ import { basename, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; export class AssetManager { diff --git a/packages/core/src/utils/file-system.utils.ts b/packages/core/src/utils/file-system.utils.ts index 52f0bb2..302e430 100644 --- a/packages/core/src/utils/file-system.utils.ts +++ b/packages/core/src/utils/file-system.utils.ts @@ -1,6 +1,6 @@ import { resolve } from 'node:path'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; import type { Nullable } from './type.utils.ts'; diff --git a/packages/core/src/utils/schema.utils.test.ts b/packages/core/src/utils/schema.utils.test.ts index 81c73f9..d204b35 100644 --- a/packages/core/src/utils/schema.utils.test.ts +++ b/packages/core/src/utils/schema.utils.test.ts @@ -1,7 +1,12 @@ import { expect } from '@std/expect'; import { describe, it } from '@std/testing/bdd'; -import { createCombinedSchema, createStringSchema } from '../../tests/schema-factory.ts'; +import { + createCombinedSchema, + createObjectSchema, + createStringSchema, + createUnknownProperty, +} from '../../tests/schema-factory.ts'; import { resolveAnyOfAndAllOf } from './schema.utils.ts'; describe('resolveAnyOfAndAllOf', () => { @@ -14,73 +19,69 @@ describe('resolveAnyOfAndAllOf', () => { expect(result).toBeUndefined(); }); - // TODO: Uncomment as soon as @std/expect has new version (https://github.com/denoland/std/pull/6065) - // it('should resolve schema from allOf and anyOf', () => { - // const schema = createObjectSchema({ - // name: 'root', - // properties: [createUnknownProperty('prop0')], - // required: ['prop0'], - // allOf: [createObjectSchema({ properties: [createUnknownProperty('prop1')], required: ['prop1'] })], - // anyOf: [createObjectSchema({ properties: [createUnknownProperty('prop2')], required: ['prop2'] })], - // }); + it('should resolve schema from allOf and anyOf', () => { + const prop0 = createUnknownProperty('prop0'); + const prop1 = createUnknownProperty('prop1'); + const prop2 = createUnknownProperty('prop2'); + const schema = createObjectSchema({ + name: 'root', + properties: [prop0], + required: ['prop0'], + allOf: [createObjectSchema({ properties: [prop1], required: ['prop1'] })], + anyOf: [createObjectSchema({ properties: [prop2], required: ['prop2'] })], + }); - // const expectedResult = expect.objectContaining( - // createObjectSchema({ - // name: 'root', - // properties: [ - // expect.objectContaining(createUnknownProperty('prop0')), - // expect.objectContaining(createUnknownProperty('prop1')), - // expect.objectContaining(createUnknownProperty('prop2')), - // ], - // required: ['prop0', 'prop1', 'prop2'], - // }), - // ); + const expectedResult = expect.objectContaining( + createObjectSchema({ + name: 'root', + properties: [prop0, prop1, prop2], + required: ['prop0', 'prop1'], + }), + ); - // const result = resolveAnyOfAndAllOf(schema, true); - // expect(result).toEqual(expectedResult); - // }); + const result = resolveAnyOfAndAllOf(schema, true); + expect(result).toEqual(expectedResult); + }); - // TODO: Uncomment as soon as @std/expect has new version (https://github.com/denoland/std/pull/6065) - // it('should merge properties from allOf and anyOf recursively', () => { - // const schema = createCombinedSchema({ - // name: 'root', - // allOf: [ - // createObjectSchema({ - // properties: [createUnknownProperty('prop1')], - // required: ['prop1'], - // }), - // ], - // anyOf: [ - // createCombinedSchema({ - // allOf: [ - // createObjectSchema({ - // properties: [createUnknownProperty('prop2')], - // required: ['prop2'], - // }), - // ], - // anyOf: [ - // createObjectSchema({ - // properties: [createUnknownProperty('prop3')], - // required: ['prop3'], - // }), - // ], - // }), - // ], - // }); + it('should merge properties from allOf and anyOf recursively', () => { + const prop1 = createUnknownProperty('prop1'); + const prop2 = createUnknownProperty('prop2'); + const prop3 = createUnknownProperty('prop3'); + const schema = createCombinedSchema({ + name: 'root', + allOf: [ + createObjectSchema({ + properties: [prop1], + required: ['prop1'], + }), + ], + anyOf: [ + createCombinedSchema({ + allOf: [ + createObjectSchema({ + properties: [prop2], + required: ['prop2'], + }), + ], + anyOf: [ + createObjectSchema({ + properties: [prop3], + required: ['prop3'], + }), + ], + }), + ], + }); - // const expectedResult = expect.objectContaining( - // createObjectSchema({ - // name: 'root', - // properties: [ - // expect.objectContaining(createUnknownProperty('prop1')), - // expect.objectContaining(createUnknownProperty('prop2')), - // expect.objectContaining(createUnknownProperty('prop3')), - // ], - // required: ['prop1'], - // }), - // ); + const expectedResult = expect.objectContaining( + createObjectSchema({ + name: 'root', + properties: [prop1, prop2, prop3], + required: ['prop1'], + }), + ); - // const result = resolveAnyOfAndAllOf(schema, true); - // expect(result).toEqual(expectedResult); - // }); + const result = resolveAnyOfAndAllOf(schema, true); + expect(result).toEqual(expectedResult); + }); }); diff --git a/packages/core/src/utils/source-builder.test.ts b/packages/core/src/utils/source-builder.test.ts index 45b5eb5..354c653 100644 --- a/packages/core/src/utils/source-builder.test.ts +++ b/packages/core/src/utils/source-builder.test.ts @@ -36,8 +36,7 @@ describe('SourceBuilder', () => { }; const sb = SourceBuilder.fromString(str, options); expect(sb.toString()).toEqual(str); - // TODO: Uncomment as soon as @std/expect has new version (https://github.com/denoland/std/pull/6065) - // expect(sb.options).toEqual(expect.objectContaining(options)); + expect(sb.options).toEqual(expect.objectContaining(options)); }); }); diff --git a/packages/core/src/utils/string-builder/string-builder.test.ts b/packages/core/src/utils/string-builder/string-builder.test.ts index be60744..a89696b 100644 --- a/packages/core/src/utils/string-builder/string-builder.test.ts +++ b/packages/core/src/utils/string-builder/string-builder.test.ts @@ -13,16 +13,15 @@ describe('fromString', () => { expect(sb.toString()).toEqual(str); }); - // TODO: Uncomment as soon as @std/expect has new version (https://github.com/denoland/std/pull/6065) - // it('should create a StringBuilder instance with the given string and options', () => { - // const str = 'test string'; - // const options: Partial = { - // newLine: '\r\n', - // }; - // const sb = StringBuilder.fromString(str, options); - // expect(sb.toString()).toEqual(str); - // expect(sb.options).toEqual(expect.objectContaining(options)); - // }); + it('should create a StringBuilder instance with the given string and options', () => { + const str = 'test string'; + const options: Partial = { + newLine: '\r\n', + }; + const sb = StringBuilder.fromString(str, options); + expect(sb.toString()).toEqual(str); + expect(sb.options).toEqual(expect.objectContaining(options)); + }); }); describe('build', () => { diff --git a/packages/kotlin/src/generators/models/model-generator.ts b/packages/kotlin/src/generators/models/model-generator.ts index 5bc1908..9877005 100644 --- a/packages/kotlin/src/generators/models/model-generator.ts +++ b/packages/kotlin/src/generators/models/model-generator.ts @@ -1,6 +1,6 @@ import { dirname } from 'node:path'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; import { diff --git a/packages/kotlin/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts b/packages/kotlin/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts index 05fd76b..b3d2563 100644 --- a/packages/kotlin/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +++ b/packages/kotlin/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts @@ -1,6 +1,6 @@ import { dirname } from 'node:path'; -// @deno-types="@types/fs-extra" +// @deno-types="npm:@types/fs-extra" import fs from 'fs-extra'; import { @@ -68,7 +68,7 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator