dzdrazil / swagger-mock-api

A connect-compatible middleware for mocking a Swagger spec API
MIT License
102 stars 20 forks source link

YAML files, are building? #11

Open brunosalgueiro opened 8 years ago

brunosalgueiro commented 8 years ago

When I try YAML files, Grunt can't execute "connect" command, if I change the file for JSON it works fine.

bruno@bruno-VirtualBox:~/Documentos/repositorio/PlataformaWeb/api/mock$ grunt Running "connect:server" (connect) task Waiting forever... Started connect web server on http://localhost:8000 Fatal error: Cannot read property 'default' of undefined

That's the grunt file

'use strict';

var path = require('path');
var mockApi = require('swagger-mock-api');

module.exports = function(grunt) {
  grunt.initConfig({
    connect: {
      server: {
        options: {
          keepalive: true,
          middleware: [
            mockApi({
                swaggerFile: path.join(__dirname, "..", "specs/financial/financing-proposal/financing-proposal.yaml"),
                watch: true // enable reloading the routes and schemas when the swagger file changes
            })
          ],
        },
      },
    },
  });
  grunt.loadNpmTasks('grunt-contrib-connect');

  grunt.registerTask('default', ['connect']);
};
dzdrazil commented 8 years ago

Interesting... I've got a hunch, I'll try to take a look at it in a day or so. It's probably a defect in swagger-parser, since the file path itself is just passed straight through to that library.

Currently, this library is a good major version behind swagger-parser, so I'll try to reproduce and see if a version bump fixes it.

If I don't see anything obvious, I may hold out a little bit as version 4 of swagger-parser is in beta right now and should bring some nice features as well.

xeniatay commented 8 years ago

+1, facing the same issue.

yingnansong commented 8 years ago

same issue +1

awmottaz commented 6 years ago

bump