Skip to content

Commit

Permalink
feat(core): bring FromSchema back into core (#801)
Browse files Browse the repository at this point in the history
* Revert "fix(core): refactoring  `FromSchema` out of core (#787)"

This reverts commit 41cacf3.

* refactor: move FromSchema to types file
  • Loading branch information
kanadgupta authored Oct 31, 2023
1 parent 6ac55ce commit f7679f4
Show file tree
Hide file tree
Showing 23 changed files with 23 additions and 36 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: 0 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"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: 1 addition & 7 deletions packages/api/src/codegen/languages/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ 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 @@ -751,7 +745,7 @@ Generated at ${createdAt}
const sourceFile = sourceDirectory.createSourceFile('types.ts', '');

sourceFile.addImportDeclarations([
{ defaultImport: 'type { FromSchema }', moduleSpecifier: 'json-schema-to-ts' },
{ defaultImport: 'type { FromSchema }', moduleSpecifier: '@readme/api-core/types' },
{ 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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';

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

Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"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.1.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { FromSchema } from 'json-schema-to-ts';

export interface ConfigOptions {
/**
* Override the default `fetch` request timeout of 30 seconds. This number should be represented
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/alby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

export type AmqpExternalRulePatch = FromSchema<typeof schemas.AmqpExternalRulePatch>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/metrotransit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

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

export type UpdatePetWithFormFormDataParam = FromSchema<typeof schemas.UpdatePetWithForm.formData>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/petstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

export type ApiResponse = FromSchema<typeof schemas.ApiResponse>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/readme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

export type Apply = FromSchema<typeof schemas.Apply>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/response-title-quirks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

export type GetAnythingMetadataParam = FromSchema<typeof schemas.GetAnything.metadata>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

export type Category = FromSchema<typeof schemas.Category>;
Expand Down
3 changes: 1 addition & 2 deletions packages/test-utils/sdks/star-trek/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"lint": "tsc --noEmit"
},
"dependencies": {
"@readme/api-core": "file:../../../../../core",
"json-schema-to-ts": "^2.9.2"
"@readme/api-core": "file:../../../../../core"
},
"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 'json-schema-to-ts';
import type { FromSchema } from '@readme/api-core/types';
import * as schemas from './schemas';

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

0 comments on commit f7679f4

Please sign in to comment.