GithubHelp home page GithubHelp logo

gersongoulart / gulp-swagger Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 13.0 43 KB

Gulp plugin that parses Swagger specs in JSON or YAML format, validates against the official Swagger 2.0 schema, dereferences all $ref pointers, including pointers to external files and generates client-side API code.

License: MIT License

JavaScript 62.91% HTML 37.09%

gulp-swagger's People

Contributors

adrian-fjellberg avatar gersongoulart avatar mennu avatar richard-reedy-volusion avatar tunurgitr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-swagger's Issues

Validate only?

Is it possible to use your package for validation only? So I could do something like:

gulp.src('./build/swagger.json')
    .pipe(swagger({
        validateOnly: true
    }))
    .pipe(prettify({
        config: '.jsbeautifyrc',
        mode: 'VERIFY_AND_WRITE'
    }))
    .pipe(gulp.dest('./public'));

The reason being that I have a (non-gulp) tool generating my JSON but it doesn't do a good validation test. I don't need anything dereferenced ... just validated. :)

Validation error when specifying "file" as response type

Hi,

When trying to validate a definition which returns file as a response type I get the following error:

Data does not match any schemas from 'oneOf'

An example of the spec which produces the error is:

responses:
    '200':
         description: OK
         schema:
             type: file

The file validates fine when viewed/edited in the swagger editor however fails when run through the gulp task.

It appears to be the same issue in the spec found here.

Thanks

SyntaxError ... but not?

First, this plug in is exactly what I need ... thanks!

Previously, I was using the swagger-cli tool to validate and compile my sources, which works fine:

$ ./node_modules/.bin/swagger bundle -o resources/documentation/api/v1/swagger.json resources/documentation/api/v1/swagger.yaml
Created resources/documentation/api/v1/swagger.json from resources/documentation/api/v1/swagger.yaml

I tried to make this part of my gulp build with the following:

gulp.task('swagger', function () {
    gulp.src('./resources/documentation/api/v1/swagger.yaml')
        .pipe(swagger('swagger.json'))
        .pipe(gulp.dest('./resources/documentation/api/v1'));
});

But now running gulp swagger, I get syntax errors:

$ gulp swagger
[11:02:19] Using gulpfile ~/Documents/workspace/my_site/gulpfile.js
[11:02:19] Starting 'swagger'...
[11:02:19] Finished 'swagger' after 7.41 ms

events.js:85
      throw er; // Unhandled 'error' event
            ^
SyntaxError: Error in Swagger definition 
Error: Error opening file "/Users/admin/Documents/workspace/my_site/resources/documentation/api/v1/definitions/ReviewImages.yaml" 
Error: ENOENT, open '/Users/admin/Documents/workspace/my_site/resources/documentation/api/v1/definitions/ReviewImages.yaml'
    at makeError (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:314:16)
    at Object.module.exports.newSyntaxError (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:84:14)
    at errBack (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/parse.js:87:14)
    at /Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/parse.js:60:7
    at crawlNextProperty (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:262:9)
    at /Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:281:13
    at Immediate.invokeCallback [as _onImmediate] (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:53:16)
    at processImmediate [as _immediateCallback] (timers.js:358:17) 

Error: Error opening file "/Users/admin/Documents/workspace/my_site/resources/documentation/api/v1/definitions/ReviewImages.yaml" 
Error: ENOENT, open '/Users/admin/Documents/workspace/my_site/resources/documentation/api/v1/definitions/ReviewImages.yaml'
    at makeError (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:314:16)
    at Object.module.exports.newError (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/util.js:67:14)
    at errorHandler (/Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/read.js:46:19)
    at /Users/admin/Documents/workspace/my_site/node_modules/gulp-swagger/node_modules/swagger-parser/lib/read.js:58:16
    at fs.js:263:20
    at FSReqWrap.oncomplete (fs.js:95:15) 

Error: ENOENT, open '/Users/admin/Documents/workspace/my_site/resources/documentation/api/v1/definitions/ReviewImages.yaml'
    at Error (native)

Any suggestions? Doing it the "old" way generates the .json I was expecting, without any errors.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.