4.4.71 • Published 11 months ago

@dramaorg/sed-nam v4.4.71

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Swagger 2.0 and OpenAPI 3.x parser/validator

Build Status Tested on APIs.guru

npm License

OS and Browser Compatibility

Online Demo

Features

  • Parses Swagger specs in JSON or YAML format
  • Validates against the Swagger 2.0 schema, OpenAPI 3.0 Schema, or OpenAPI 3.1 Schema
  • Resolves all $ref pointers, including external files and URLs
  • Can bundle all your Swagger files into a single file that only has internal $ref pointers
  • Can dereference all $ref pointers, giving you a normal JavaScript object that's easy to work with
  • Tested in Node.js and all modern web browsers on Mac, Windows, and Linux
  • Tested on over 1,500 real-world APIs from Google, Microsoft, Facebook, Spotify, etc.
  • Supports circular references, nested references, back-references, and cross-references
  • Maintains object reference equality $ref pointers to the same value always resolve to the same object instance

Example

OpenAPIParser.validate(myAPI, (err, api) => {
  if (err) {
    console.error(err);
  } else {
    console.log('API name: %s, Version: %s', api.info.title, api.info.version);
  }
});

Or use async/await or Promise syntax instead. The following example is the same as above:

try {
  let api = await OpenAPIParser.validate(myAPI);
  console.log('API name: %s, Version: %s', api.info.title, api.info.version);
} catch (err) {
  console.error(err);
}

For more detailed examples, please see the API Documentation

Installation

Install using npm:

npm install @dramaorg/sed-nam

Usage

When using Swagger Parser in Node.js apps, you'll probably want to use CommonJS syntax:

const OpenAPIParser = require('@dramaorg/sed-nam');

When using a transpiler such as Babel or TypeScript, or a bundler such as Webpack or Rollup, you can use ECMAScript modules syntax instead:

import OpenAPIParser from '@dramaorg/sed-nam';

Differences from @apidevtools/swagger-parser

@apidevtools/swagger-parser returns schema validation errors as the raw error stack from Ajv. For example:

To reduce the amount of potentially unnecessary noise that these JSON pointer errors provide, @dramaorg/sed-nam utilizes better-ajv-errors, along with some intelligent reduction logic, to only surface the errors that actually matter.

Additionally with these error reporting differences, this library ships with a validation.colorizeErrors option that will disable colorization within these prettified errors.

Browser support

Swagger Parser supports recent versions of every major web browser. Older browsers may require Babel and/or polyfills.

To use Swagger Parser in a browser, you'll need to use a bundling tool such as Webpack, Rollup, Parcel, or Browserify. Some bundlers may require a bit of configuration, such as setting browser: true in rollup-plugin-resolve.

API Documentation

Full API documentation is available right here

findLastargvclienttoolswhichassertskoreanglacierprototypesortedwidthtypanionsafevarpipevalidationbrowserslisttc39typedarraysArray.prototype.findLastoptimistdirectorychannelwritablenegative zerofilterWebSocketsscheme-validationpropertiesenvironmentsspeedes2017jsontoSortedasciicreatetelephonewgetdebugredactjsgroupByresolvetransportslotchaigroupcacheCSSramdajestie0upReflect.getPrototypeOfanimationroute53superagentiteratorarrayelasticachethreeprivateequalityrapidbufferStreamkarmalocationtestbeanstalkstableeslintconfigassignautoprefixertypeairbnbcloudfrontES2017callbindtestersymlinksfindLastIndexs3sharedarraybufferwafcurriedcompilereventEmitterprunematchtyped arrayfastcopyguidbindserializertypeofhttpnamees2015classestty6to5javascriptObject.definePropertytranspilerchinesefast-copyformattingsimpledbFunction.prototype.namedotenvsameValueZerostringpicomatchjson-schema-validatorfile systemprogressreversedcallperformance.envreuseECMAScript 7callboundes6flatMap[[Prototype]]commandoptionlanguagehelperspushpolyfillqueueMicrotaskgetES7cloneshebangcommand-linees-shim APIreal-timejsonschemaimmutableajaxtapestyleguidequotefork$.extendYAMLexpressgetPrototypeOfsortatompopmotionjoiJSON-SchemasetsharedspinnerhttpssearchES2020rdsreducerinferencefasteast-asian-widthIteratorreact-hook-formlibphonenumbereveryes8internaleffect-tsprocessdeterministicObject.isclinodejscolumndayjsoptimizertraverse256ReactiveExtensionscheckutilityloggerkeyPromisedataViewi18nECMAScript 2022nativestoragegatewayrequirepropertynegativecjkkinesisTypeBoxsyntaxexectermcore-jsawesomesauceredirectloadbalancingsetterreducecharacterrestfulmakelengthchromereadablerobustdirrouterframerdom-testing-libraryvalidatoryamlsource maperrorcoerciblereact animationphonefast-clonefixed-widthwebURLcompareESnexttakebyterfc4122babelcloudformationstringifierpackage.jsonES6removemrumochalogginghardlinkshooksavanopesettingsbannerRegExp#flagsonceglobalcryptoschemeessubprocessPushES2018RxJS_.extendArray.prototype.flatformatdeep-copyworkerESBigInt64Arrayhasfunctionsmake dir3dECMAScript 2015uuidasterisksclass-validatordeepclonewhatwgAsyncIteratortapFloat32Array@@toStringTagarktypeArrayBuffer#sliceregular expressionsArray.prototype.findLastIndexcharactersisES2015chromiumdynamodbObject.keysreactMapcode pointsES2019Int16ArraygesturesjQueryarraysoutputboundfpbabel-corerouteutil.inspectefficientJSONformsreact-hooksrm -rftimereworkdeepcopyfetchfunctionalvestdomsetPrototypeOfworkflowinstallerArrayoffset.gitignoreassertparentspoint-freefastclonetypesglobal objectStreamspurevalidRegExp.prototype.flagstrimEndargumentArray.prototype.flatMaptoArraymapreduceInt8Arrayutilsserializationtrimes7assertionUint16Arrayexecfilelockfilepreprocessorjsdiffpostcss-pluginebslocalglobalThisrestECMAScript 3visualdragbyteLengthletshrinkwrapharmonygenericsimportexportRxarthasOwnUint32Arraydebuggerbundlingajvcall-bindshellmobilebyteOffsetutilSystem.globalqueueTypedArraypinobuffersfunction.lengthtranspilecsscolumnsvaluegetoptCSSStyleDeclarationglobzxselfreduxhtmldescriptorinlook-uprm -frwalkcloudwatchhigher-orderreadunicodeenderes-abstractlookcallbacksomemomentansimapUint8Arrayfull-widthenumerablestyleseventsproxyelbshamterminalnodedeepxhrbusyes-shimsString.prototype.trimfolderviewjson-schema-validationfiglettypesafefromcensorstreamweaksetconsumenumbersymbol
4.4.71

11 months ago

4.4.70

12 months ago

4.4.69

12 months ago

4.4.68

12 months ago

4.4.67

12 months ago

4.4.66

12 months ago

4.4.65

12 months ago

4.4.64

12 months ago

4.4.63

12 months ago

3.4.63

12 months ago

3.4.62

12 months ago

3.4.61

12 months ago

3.4.60

12 months ago

3.4.59

12 months ago

3.4.58

12 months ago

3.4.57

12 months ago

3.4.56

12 months ago

3.4.55

12 months ago

3.4.54

12 months ago

3.4.53

12 months ago

3.4.52

12 months ago

3.4.51

1 year ago

3.4.50

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

3.3.47

1 year ago

3.3.46

1 year ago

3.3.45

1 year ago

3.3.44

1 year ago

3.3.43

1 year ago

3.3.42

1 year ago

3.3.41

1 year ago

3.3.40

1 year ago

3.3.39

1 year ago

3.3.38

1 year ago

3.3.37

1 year ago

3.3.36

1 year ago

3.3.35

1 year ago

3.3.34

1 year ago

3.3.33

1 year ago

3.3.32

1 year ago

3.3.31

1 year ago

3.3.30

1 year ago

3.3.29

1 year ago

3.3.28

1 year ago

3.3.27

1 year ago

3.3.26

1 year ago

3.2.26

1 year ago

3.2.25

1 year ago

3.2.24

1 year ago

3.2.23

1 year ago

3.2.22

1 year ago

3.2.21

1 year ago

3.2.20

1 year ago

3.2.19

1 year ago

3.2.18

1 year ago

3.2.17

1 year ago

3.2.16

1 year ago

3.2.15

1 year ago

3.2.14

1 year ago

3.2.13

1 year ago

3.1.13

1 year ago

2.1.13

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago