Skip to content

Commit

Permalink
fix(core): refactoring FromSchema out of core (#787)
Browse files Browse the repository at this point in the history
* fix(core): moving our `FromSchema` exports into the `types` file

* fix(core): moving `json-schema-to-ts` back over to being an sdk dep
  • Loading branch information
erunion authored Oct 25, 2023
1 parent cd9e22c commit 41cacf3
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"figures": "^5.0.0",
"httpsnippet-client-api": "file:../httpsnippet-client-api",
"js-yaml": "^4.1.0",
"json-schema-to-ts": "^2.9.2",
"license": "^1.0.3",
"lodash.camelcase": "^4.3.0",
"lodash.deburr": "^4.1.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/api/src/codegen/languages/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export default class TSGenerator extends CodeGenerator {
url: 'https://tsup.egoist.dev/',
version: '^7.2.0',
},
'json-schema-to-ts': {
dependencyType: 'production',
reason: 'Required for TypeScript type handling.',
url: 'https://npm.im/json-schema-to-ts',
version: '^2.9.2',
},
typescript: {
dependencyType: 'development',
reason: 'Required for `tsup`.',
Expand Down Expand Up @@ -753,7 +759,7 @@ Generated at ${createdAt}
const sourceFile = sourceDirectory.createSourceFile('types.ts', '');

sourceFile.addImportDeclarations([
{ defaultImport: 'type { FromSchema }', moduleSpecifier: '@readme/api-core/lib' },
{ defaultImport: 'type { FromSchema }', moduleSpecifier: 'json-schema-to-ts' },
{ defaultImport: '* as schemas', moduleSpecifier: './schemas' },
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/lockfileSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';

import { SupportedLanguages } from './codegen/factory.js';

Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"caseless": "^0.12.0",
"datauri": "^4.1.0",
"fetch-har": "^11.0.1",
"json-schema-to-ts": "^2.9.2",
"json-schema-traverse": "^1.0.0",
"lodash.merge": "^4.6.2",
"oas": "^23.0.0",
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { FromSchema } from 'json-schema-to-ts';

import getJSONSchemaDefaults from './getJSONSchemaDefaults.js';
import parseResponse from './parseResponse.js';
import prepareAuth from './prepareAuth.js';
import prepareParams from './prepareParams.js';
import prepareServer from './prepareServer.js';

export { FromSchema, getJSONSchemaDefaults, parseResponse, prepareAuth, prepareParams, prepareServer };
export { getJSONSchemaDefaults, parseResponse, prepareAuth, prepareParams, prepareServer };
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/alby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/alby/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type AmqpExternalRulePatch = FromSchema<typeof schemas.AmqpExternalRulePatch>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/metrotransit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/metrotransit/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type Agency = FromSchema<typeof schemas.Agency>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/operationid-quirks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/optional-payload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/optional-payload/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type UpdatePetWithFormFormDataParam = FromSchema<typeof schemas.UpdatePetWithForm.formData>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/petstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/petstore/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type ApiResponse = FromSchema<typeof schemas.ApiResponse>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/readme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/readme/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type Apply = FromSchema<typeof schemas.Apply>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/response-title-quirks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type GetAnythingMetadataParam = FromSchema<typeof schemas.GetAnything.metadata>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/simple/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type Category = FromSchema<typeof schemas.Category>;
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/sdks/star-trek/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"prepare": "tsup"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core"
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
},
"devDependencies": {
"tsup": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/sdks/star-trek/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FromSchema } from '@readme/api-core/lib';
import type { FromSchema } from 'json-schema-to-ts';
import * as schemas from './schemas';

export type AnimalBase = FromSchema<typeof schemas.AnimalBase>;
Expand Down

0 comments on commit 41cacf3

Please sign in to comment.