JSPM

insomnia-oas-converter

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q52829F
  • License MIT

Utility to convert insomnia documents to OpenAPI 3.0 specification.

Package Exports

  • insomnia-oas-converter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (insomnia-oas-converter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Insomnia OAS Converter

This project converts insomnia to openapi specification (3.0.0). This package is an effort of improving the another package Swaggymnia

so that I can use couple of extra features such as:

  • Insomnia templates in path ({{ }} syntax in urls)
  • Proper URL formatting and splitting query strings
  • Supporting oneOf

Insomnia being built on top of javascript framework, it is nice to have the converter in Javascript itself (you can use this as a plugin)

Quickstart

Install this project using npm

npm i insomnia-oas-converter

Once installed, you can access to converter in your javascript

var SchemaConventer = require('insomnia-oas-converter');

// Your openapi spec config
let openapiConfig = {
    "title": "My Api",
    "description": "A Very cool api",
    "version": "1.0.0",
    "baseUrl": "http://example.tld"
};

// Read insomnia exported (in v4 format) json file into a dict
let insomniaExportedInput = {
    "_type": "export",
    "__export_format": 4,
    "__export_date": "2020-09-03T15:26:50.615Z",
    "__export_source": "insomnia.desktop.app:v2020.4.0-beta.4",
    "resources": [
      ...
    ]
}

let schema = new SchemaConventer(insomniaExportedInput, openapiConfig)
let spec = schema.convert();

// Convert to yaml
let spec_in_yaml = spec.as_yaml()

// Convert to json
let spec_in_json = spec.as_json()

// Or you can simply get the spec is javascript object
let spec_dict = spec.as_dict()

SchemaConventer

SchemaConventer is responsible for handling the insomnia input and perform some validations on it. It also exposes a convert method, after the validations has ran.

convert

convert gives you a instance of SpecExporter which allows you to export the specification as yaml, json or plain javascript object.

SpecExporter

SpecExporter implements the yaml package to output the converted openapi spec to yaml. It natively supports json and dict.

Testing

TODO

Author

References