How to use the swagger-parser function in swagger-parser

To help you get started, we’ve selected a few swagger-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apiaryio / fury-adapter-swagger / src / parser.js View on Github external
parse(done) {
    const {
      Category, ParseResult, SourceMap,
    } = this.minim.elements;
    const swaggerParser = new SwaggerParser();

    this.result = new ParseResult();

    // First, we load the YAML if it is a string, and handle any errors.
    let loaded;
    try {
      loaded = _.isString(this.source) ? yaml.safeLoad(this.source) : this.source;
    } catch (err) {
      this.createAnnotation(ANNOTATIONS.CANNOT_PARSE, null,
        (err.reason || 'Problem loading the input'));

      if (err.mark) {
        this.result.first().attributes.set('sourceMap', [
          new SourceMap([[err.mark.position, 1]]),
        ]);
      }
github shastajs / sutro / test / index.js View on Github external
/*global it: true, describe: true */
/*eslint no-console: 0*/
import pick from 'lodash.pick'
import should from 'should'
import sutro from '../src'
import request from 'supertest'
import express from 'express'
import Parser from 'swagger-parser'

const parser = new Parser()
const users = [
  { id: 0, name: 'foo' },
  { id: 1, name: 'bar' },
  { id: 2, name: 'baz' }
]

const passengers = [
  { name: 'todd' },
  { name: 'rob' }
]
const cars = [
  [
    { id: 0, name: 'foo', passengers },
    { id: 1, name: 'bar', passengers },
    { id: 2, name: 'baz', passengers }
  ],

swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis