npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openapi-integration/schema-resolver

v0.1.1

Published

A tool for resolving openAPI json schema to typescript type definition.

Readme

OpenAPI schema resolver

this is a tool for resolving OpenAPI schema.

For the first part, it can convert json format OpenAPI schema to TypeScript type definition.

from

 {
  "components": {
    "schemas": {
      "ScheduleVO": {
        "type": "object",
        "properties": {
          "team": {
            "type": "string"
          },
          "schedules": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/BookVO"
              }
            }
          },
          "shiftId": {
            "type": "string"
          }
        },
        "title": "ScheduleVO"
      },
      "BookVO": {
        "type": "object",
        "properties": {
          "price": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "nullable": true
          }
        },
        "title": "BookVO"
      }
    }
  }
}

to

const definitions = {
  ScheduleVO: {
    "schedules?": "IBookVo[][] | null",
    "shiftId?": "string",
    "team?": "string",
  },
  BookVO: {
    "address?": "string | null",
    "price?": "string",
  },
};

Secondly, it can resolve json OpenAPI 'path' to request params and response material.

These material can help you generate request function you need in your project.

Example:

How to use

Install

npm install @openapi-integration/schema-resolver

or

yarn add @openapi-integration/schema-resolver

Functional(all the usage can find in unit test code)

There are three function in this tool:

  • SchemaResolver
  • DefinitionsResolver
  • PathResolver

SchemaResolver

SchemaResolver can resolve a OpenAPI schema object as its type:

SchemaResolver.of({
  results: {},
  schema,
  key,
  parentKey,
})
  .resolve()
  .getSchemaType();
input:
  • results(Record): Will assign enum resolved type to this field(will change this operation)
  • schema(Schema): OpenAPI schema object
  • key(string): OpenAPI schema object key name
  • parentKey(string): current schema's parent key name, will use this parent key to join enum name
output - a string(for one field) or a json object(for record type) for resolved schema's type:
"IBookDetailVo"

or

{
  "authorName?": "string | null"
}

DefinitionsResolver

DefinitionsResolver can organize all resolved schema in OpenAPI.components as interface in TypeScript.

DefinitionsResolver.of(openAPI.components)
  .scanDefinitions()
  .toDeclarations();
output:
const definitions = DefinitionsResolver
  .of(openAPI.components)
  .scanDefinitions()
  .resolvedDefinitions;

console.log(definitions);
// {
//   AttachmentBO: {
//     "authorName?": "string",
//     "createdDate?": "number",
//     "fileName?": "string",
//     "id?": "string",
//     "mimeType?": "string",
//     "path?": "string",
//   },
// }

const interfaceStrings = DefinitionsResolver
  .of(openAPI.components)
  .scanDefinitions()
  .toDeclarations()

console.log(interfaceStrings);
// ["export interface IAttachmentBo {\n        'authorName'?: string;\n'createdDate'?: number;\n'fileName'?: string;\n'id'?: string;\n'mimeType'?: string;\n'path'?: string;\n      }",]

PathResolver

PathResolver can resolve OpenAPI.paths to object which contain all definition for request.

PathResolver.of(openAPI.paths).resolve();
output:

resolvedPaths:

  • THeader(record): request header for request
  • TReq(record): request function params for request
  • TResp(record | string): response type
  • bodyParams(array): request body params
  • pathParams(array): request path params
  • queryParams(array): request query params
  • formDataParams(array): request form data params
  • method(string): request method
  • operationId(string): request id, a unique identifier for a request
  • requestBody(string): request body type name
  • url(string): request url with params
const resolvedPaths = PathResolver.of(openAPI.paths).resolve().resolvedPaths;

console.log(resolvedPaths);
// [{
//   THeader: {
//     Authorities: "string",
//     "User-Id": "string",
//     "User-Name": "string",
//   },
//   TReq: {
//     uploadAttachmentUsingPOSTRequest: {
//       attachment: "FormData",
//     },
//   },
//   TResp: "IAttachmentBo",
//   bodyParams: [],
//   formDataParams: [],
//   method: "post",
//   operationId: "uploadAttachmentUsingPOST",
//   pathParams: [],
//   queryParams: [],
//   requestBody: "uploadAttachmentUsingPOSTRequest",
//   url: "/",
// },]

contentType - contentType for each request:

record - key: operationId, value: contentType

const contentType = PathResolver.of(openAPI.paths).resolve().contentType

console.log(contentType);
// {
//   UpdateBookJourneyUsingPOST: "application/json",
//   updateBookByIdUsingPUT: "application/json",
//   uploadAttachmentUsingPOST: "multipart/form-data",
//   uploadDocumentUsingPOST: "multipart/form-data",
// }

extraDefinitions - definitions for enum type

const extraDefinitions = PathResolver.of(openAPI.paths).resolve().extraDefinitions;

console.log(extraDefinitions);
// {
//   "FromFrom#EnumTypeSuffix": [
//   "AAA",
//   "BBB"
// ]
// }