{"id":18311894,"url":"https://github.com/teobler/openapi-schema-resolver","last_synced_at":"2026-05-20T14:11:11.848Z","repository":{"id":57133417,"uuid":"411923748","full_name":"teobler/openapi-schema-resolver","owner":"teobler","description":"A tool for resolving openAPI json schema to typescript type definition.","archived":false,"fork":false,"pushed_at":"2021-10-03T03:24:17.000Z","size":200,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-03T08:07:58.546Z","etag":null,"topics":["code-generation","generator","openapi","schema","swagger","type","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@openapi-integration/schema-resolver","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teobler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-30T04:36:25.000Z","updated_at":"2023-03-07T12:36:25.000Z","dependencies_parsed_at":"2022-09-03T20:21:54.738Z","dependency_job_id":null,"html_url":"https://github.com/teobler/openapi-schema-resolver","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/teobler/openapi-schema-resolver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teobler%2Fopenapi-schema-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teobler%2Fopenapi-schema-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teobler%2Fopenapi-schema-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teobler%2Fopenapi-schema-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teobler","download_url":"https://codeload.github.com/teobler/openapi-schema-resolver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teobler%2Fopenapi-schema-resolver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267327534,"owners_count":24069442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","generator","openapi","schema","swagger","type","typescript"],"created_at":"2024-11-05T16:21:06.480Z","updated_at":"2026-05-20T14:11:11.803Z","avatar_url":"https://github.com/teobler.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI schema resolver\n\nthis is a tool for resolving OpenAPI schema.\n\nFor the first part, it can convert json format OpenAPI schema to TypeScript type definition.\n\nfrom\n\n```json\n {\n  \"components\": {\n    \"schemas\": {\n      \"ScheduleVO\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"team\": {\n            \"type\": \"string\"\n          },\n          \"schedules\": {\n            \"type\": \"array\",\n            \"nullable\": true,\n            \"items\": {\n              \"type\": \"array\",\n              \"items\": {\n                \"$ref\": \"#/components/schemas/BookVO\"\n              }\n            }\n          },\n          \"shiftId\": {\n            \"type\": \"string\"\n          }\n        },\n        \"title\": \"ScheduleVO\"\n      },\n      \"BookVO\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"price\": {\n            \"type\": \"string\"\n          },\n          \"address\": {\n            \"type\": \"string\",\n            \"nullable\": true\n          }\n        },\n        \"title\": \"BookVO\"\n      }\n    }\n  }\n}\n```\n\nto\n\n```typescript\nconst definitions = {\n  ScheduleVO: {\n    \"schedules?\": \"IBookVo[][] | null\",\n    \"shiftId?\": \"string\",\n    \"team?\": \"string\",\n  },\n  BookVO: {\n    \"address?\": \"string | null\",\n    \"price?\": \"string\",\n  },\n};\n```\n\nSecondly, it can resolve json OpenAPI 'path' to request params and response material.\n\nThese material can help you generate request function you need in your project.\n\nExample:\n\n- [swr-request-generator](https://github.com/teobler/swr-request-generator)\n\n## How to use\n\n### Install\n\n`npm install @openapi-integration/schema-resolver`\n\nor\n\n`yarn add @openapi-integration/schema-resolver`\n\n### Functional(all the usage can find in unit test code)\n\nThere are three function in this tool:\n\n- SchemaResolver\n- DefinitionsResolver\n- PathResolver\n\n#### SchemaResolver\n\nSchemaResolver can resolve a OpenAPI schema object as its type:\n\n```typescript\nSchemaResolver.of({\n  results: {},\n  schema,\n  key,\n  parentKey,\n})\n  .resolve()\n  .getSchemaType();\n```\n\n##### input:\n\n- results(Record): Will assign enum resolved type to this field(will change this operation)\n- schema(Schema): OpenAPI schema object\n- key(string): OpenAPI schema object key name\n- parentKey(string): current schema's parent key name, will use this parent key to join enum name\n\n##### output - a string(for one field) or a json object(for record type) for resolved schema's type:\n\n```typescript\n\"IBookDetailVo\"\n```\n\nor\n\n```json\n{\n  \"authorName?\": \"string | null\"\n}\n```\n\n#### DefinitionsResolver\n\nDefinitionsResolver can organize all resolved schema in OpenAPI.components as interface in TypeScript.\n\n```typescript\nDefinitionsResolver.of(openAPI.components)\n  .scanDefinitions()\n  .toDeclarations();\n```\n\n##### output:\n\n```typescript\nconst definitions = DefinitionsResolver\n  .of(openAPI.components)\n  .scanDefinitions()\n  .resolvedDefinitions;\n\nconsole.log(definitions);\n// {\n//   AttachmentBO: {\n//     \"authorName?\": \"string\",\n//     \"createdDate?\": \"number\",\n//     \"fileName?\": \"string\",\n//     \"id?\": \"string\",\n//     \"mimeType?\": \"string\",\n//     \"path?\": \"string\",\n//   },\n// }\n\nconst interfaceStrings = DefinitionsResolver\n  .of(openAPI.components)\n  .scanDefinitions()\n  .toDeclarations()\n\nconsole.log(interfaceStrings);\n// [\"export interface IAttachmentBo {\\n        'authorName'?: string;\\n'createdDate'?: number;\\n'fileName'?: string;\\n'id'?: string;\\n'mimeType'?: string;\\n'path'?: string;\\n      }\",]\n```\n\n#### PathResolver\n\nPathResolver can resolve OpenAPI.paths to object which contain all definition for request.\n\n```typescript\nPathResolver.of(openAPI.paths).resolve();\n```\n\n##### output:\n\nresolvedPaths:\n- THeader(record): request header for request\n- TReq(record): request function params for request\n- TResp(record | string): response type\n- bodyParams(array): request body params\n- pathParams(array): request path params\n- queryParams(array): request query params\n- formDataParams(array): request form data params\n- method(string): request method\n- operationId(string): request id, a unique identifier for a request\n- requestBody(string): request body type name\n- url(string): request url with params\n\n```typescript\nconst resolvedPaths = PathResolver.of(openAPI.paths).resolve().resolvedPaths;\n\nconsole.log(resolvedPaths);\n// [{\n//   THeader: {\n//     Authorities: \"string\",\n//     \"User-Id\": \"string\",\n//     \"User-Name\": \"string\",\n//   },\n//   TReq: {\n//     uploadAttachmentUsingPOSTRequest: {\n//       attachment: \"FormData\",\n//     },\n//   },\n//   TResp: \"IAttachmentBo\",\n//   bodyParams: [],\n//   formDataParams: [],\n//   method: \"post\",\n//   operationId: \"uploadAttachmentUsingPOST\",\n//   pathParams: [],\n//   queryParams: [],\n//   requestBody: \"uploadAttachmentUsingPOSTRequest\",\n//   url: \"/\",\n// },]\n```\n\ncontentType - contentType for each request:\n\nrecord - key: operationId, value: contentType\n\n```typescript\nconst contentType = PathResolver.of(openAPI.paths).resolve().contentType\n\nconsole.log(contentType);\n// {\n//   UpdateBookJourneyUsingPOST: \"application/json\",\n//   updateBookByIdUsingPUT: \"application/json\",\n//   uploadAttachmentUsingPOST: \"multipart/form-data\",\n//   uploadDocumentUsingPOST: \"multipart/form-data\",\n// }\n```\n\nextraDefinitions - definitions for enum type\n\n```typescript\nconst extraDefinitions = PathResolver.of(openAPI.paths).resolve().extraDefinitions;\n\nconsole.log(extraDefinitions);\n// {\n//   \"FromFrom#EnumTypeSuffix\": [\n//   \"AAA\",\n//   \"BBB\"\n// ]\n// }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteobler%2Fopenapi-schema-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteobler%2Fopenapi-schema-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteobler%2Fopenapi-schema-resolver/lists"}