Skip to content

Commit

Permalink
Refactor JSON schema by removing empty "enum" arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Mearman committed Jan 31, 2024
1 parent a126b42 commit 13576f7
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 40 deletions.
2 changes: 2 additions & 0 deletions __tests__/clients/typescript-fetch/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as OpenAlexApi from "@mearman/openalex-typescript-fetch";
import { wait } from "../../util/wait";

jest.retryTimes(3, {logErrorsBeforeRetry: true});

describe("InfoApi", () => {
const infoApi = new OpenAlexApi.InfoApi()
test("getRoot", async () => {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/clients/typescript-node/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as OpenAlexApi from "@mearman/openalex-typescript-node";
import { wait } from "../../util/wait";

jest.retryTimes(3, {logErrorsBeforeRetry: true});

describe("InfoApi", () => {
const infoApi = new OpenAlexApi.InfoApi()
test("getRoot", async () => {
Expand Down
26 changes: 8 additions & 18 deletions __tests__/clients/typescript/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
// import * as OpenAlex from "@mearman/openalex-typescript";
//
// describe("typescript", () => {
// const infoApi = new OpenAlex.InfoApi(OpenAlex.createConfiguration());
//
// it("should work", async () => {
// const response = await infoApi.getRoot()
// expect(response).toBeDefined();
// console.log(response);
// })
// })
import { createConfiguration, InfoApi } from "@mearman/openalex-typescript/dist/index";

import * as Api from "@mearman/openalex-typescript";

console.log(Object.keys(Api));

describe("typescript-node", () => {
it("should work", () => {
expect(true).toBe(true);
});
describe("InfoApi", () => {
let configuration = createConfiguration();
const infoApi = new InfoApi(configuration)
test("getRoot", async () => {
const response = await infoApi.getRoot()
expect(response).toBeDefined();
})
})
1 change: 1 addition & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const namedDocs: [string, string][] = [
["3.0 Dereferenced", "generated/openapi.dereferenced.3.0.json"],
]
describe.each(namedDocs)(`%s`, (name, location) => {
console.log("reading", name, "from", location)
const doc: OpenAPI.Document = JSON.parse(fs.readFileSync(location).toString())
jestOpenAPI(doc as unknown as OpenAPI.Document);
test("Root url", async () => {
Expand Down
1 change: 0 additions & 1 deletion generated/openapi.3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -3450,7 +3450,6 @@
"workSelectSchema": {
"type": "array",
"items": {
"enum": [],
"allOf": [
{
"$ref": "#/components/schemas/workAttributes"
Expand Down
2 changes: 0 additions & 2 deletions generated/openapi.dereferenced.3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -17069,7 +17069,6 @@
"type": "string"
}
],
"enum": [],
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -18025,7 +18024,6 @@
"type": "string"
}
],
"enum": [],
"type": "string"
},
"type": "array"
Expand Down
2 changes: 0 additions & 2 deletions generated/openapi.dereferenced.json
Original file line number Diff line number Diff line change
Expand Up @@ -17440,7 +17440,6 @@
"type": "string"
}
],
"enum": [],
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -18490,7 +18489,6 @@
"type": "string"
}
],
"enum": [],
"type": "string"
},
"type": "array"
Expand Down
1 change: 0 additions & 1 deletion generated/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,6 @@
"$ref": "#/components/schemas/baseSelectionAttributes"
}
],
"enum": [],
"type": "string"
},
"type": "array"
Expand Down
3 changes: 2 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { jsWithTsESM } from 'ts-jest/presets';
// import { jsWithBabelESM } from 'ts-jest/presets';

const jestConfig: JestConfigWithTsJest = {
maxConcurrency: 1,
testEnvironment: 'node',
transform: {
...jsWithTsESM.transform,
},
verbose: true,
testEnvironment: 'node'
};

export default jestConfig;
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@types/uuid": "^9.0.7",
"axios": "^1.6.5",
"jest": "^29.7.0",
"jest-expect-openapi": "^1.0.0",
"jest-openapi": "^0.14.2",
"json-schema-to-ts": "^3.0.0",
"rimraf": "^5.0.5",
Expand All @@ -41,7 +42,7 @@
},
"scripts": {
"build": "wireit",
"build:client:typescript": "wireit",
"build:client:typescript": "yarn workspaces foreach -A run build",
"build:generated": "yarn workspaces foreach -A run tsc --noEmit",
"convert:markdown:notebook": "wireit",
"generate": "wireit",
Expand All @@ -63,15 +64,6 @@
"openapitools.json"
]
},
"build:client:typescript": {
"dependencies": [
"generate:code",
"./generated/clients/typescript:build"
],
"files": [
"./src/**/*.ts"
]
},
"build:clients": {
"dependencies": [
"build:client:typescript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { workAttributes } from "~/spec/components/schemas/works/workAttributes";
const workSelectSchema: SchemaObject = {
type: "array",
items: {
enum: [],
allOf: [
refSchema({ workAttributes }),
refSchema({ baseSelectionAttributes }),
refSchema({workAttributes}),
refSchema({baseSelectionAttributes}),
],
type: "string",
}
Expand All @@ -20,5 +19,5 @@ export const workAttributeSelectionParameter: ParameterObject = {
required: false,
style: "form",
explode: false,
schema: refSchema({ workSelectSchema }),
schema: refSchema({workSelectSchema}),
} satisfies ParameterObject;

0 comments on commit 13576f7

Please sign in to comment.