Giter VIP home page Giter VIP logo

swagger-express's People

Contributors

theganyo avatar whitlockjc 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swagger-express's Issues

Validation error with swagger-express-mw 0.6.0

I have a swagger project which uses swagger-express-mw 0.1.0. The path definitions for swagger.yaml file has been externalized into another file. When I start the project using swagger project start, everything works fine.

I tried upgrading to swagger-express-mw version to 0.6.0 and the error just pops out while starting project.

Error in callback! Tossing to global error handler. Error: Swagger validation errors:

Is there any bug fixes applied recently which has caused schema resolution to fail? Please help.

Question

Any plan to tag or release version 0.6.0 ?
Or a guide to use with generated swagger-node projects?

Module not found: Error: Can't resolve 'swagger-schema-official/schema'

Hi ,
I'm getting below error. Please help me to get rid of this error.
I have raised ticket in sway module and got reply that unable to reproduce it.

I'm getting this error while run build using webpack after implementing Typescript in my project.

npm version: "1.0.0"
node version: v8.9.1
npm version: 5.5.1

ERROR in ./node_modules/sway/lib/validation/validators.js
Module not found: Error: Can't resolve 'swagger-schema-official/schema' in '/home/project/node_modules/sway/lib/validation'
@ ./node_modules/sway/lib/validation/validators.js 31:20-61
@ ./node_modules/sway/lib/types/api.js
@ ./node_modules/sway/index.js
@ ./node_modules/swagger-node-runner/index.js
@ ./node_modules/swagger-express-mw/lib/index.js

Multipart -> Error: req.files must be provided for 'formData' parameters of type 'file'

Hi,

There is an issue arround multipart entrypoint. Is not possible to upload file!

There is always this error message from apigee-127/sway librairy:

Error: req.files must be provided for 'formData' parameters of type 'file'

This my package.json dependencies:

  "dependencies": {
    "express": "^4.16.2",
    "swagger-express-mw": "~0.7.0"
  },

And the definition of my entrypoint:

/upload:
    x-swagger-router-controller: upload
    post:
      tags:
      - labels
      description: Upload file 
      consumes:
      - multipart/form-data
      operationId: upload
      parameters:
      - name: myFile
        type: file
        in: formData
        description: The file to upload.
        required: true
      - name: myText
        type: string
        in: formData
        description: Description of the file
        required: true
      responses:
        "201":
          description: Success
          schema:
            $ref: "#/definitions/UploadResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"

Could I hope an update or a fix for this issue?
If not, could you tell me what direction to take?

How to allow for nullable values

I know that OpenApi 2 doesn't support nullable values.

Is there a way to selectively disable type checking in swagger-express-mw ? Perhaps with sime x-??? tag ?

How to get data from response object

Hi guy I am using swagger for my project, The problem what i am facing "unable to get data from the response object" Can some one help me to identified what i have done wrong below ?

var SwaggerExpress = require('swagger-express-mw');
var app = require('express')();

//this is done for schema validation
 var schemaValidator = require('./api/middlewares/schema_mw/schemaValidator');
 var validator = new schemaValidator();
 var SwaggerUi = require('swagger-tools/middleware/swagger-ui');
 module.exports = app; // for testing

 var config = {
    appRoot: __dirname // required config
  } ;

 SwaggerExpress.create(config, function (err, swaggerExpress) {

 if (err) {
      throw err;
 }

 //install middleware to validate request object
 app.use(validator.requestValidator.bind(validator));
app.use(SwaggerUi(swaggerExpress.runner.swagger));
// install middleware
 swaggerExpress.register(app);

 var middleware = function(req, res , next){
       res.end = function(data , encoding) {
      console.log(data);
 }
  app.use(middleware);
}
 var port = process.env.PORT || 10010;
 app.listen(port);

});

Ajax Query Preflight Failing

I am not seeing any examples on how to handle an OPTIONS request sent in during the preflight check of an Ajax query. I have resolved CORS issues but now am receiving the following exception:

Error: Path [/ping] defined in Swagger, but OPTIONS operation is not.
    at middleware (/var/node/api/node_modules/swagger-express-mw/node_modules/swagger-node-runner/lib/connect_middleware.js:31:21)
    at Layer.handle [as handle_request] (/var/node/api/node_modules/express/lib/router/layer.js:82:5)
    at trim_prefix (/var/node/api/node_modules/express/lib/router/index.js:302:13)
    at /var/node/api/node_modules/express/lib/router/index.js:270:7
    at Function.proto.process_params (/var/node/api/node_modules/express/lib/router/index.js:321:12)
    at next (/var/node/api/node_modules/express/lib/router/index.js:261:10)
    at /var/node/api/app.js:38:8
    at Layer.handle [as handle_request] (/var/node/api/node_modules/express/lib/router/layer.js:82:5)
    at trim_prefix (/var/node/api/node_modules/express/lib/router/index.js:302:13)
    at /var/node/api/node_modules/express/lib/router/index.js:270:7

It is clear that I need to define an OPTIONS operation... but how... and what is expected? Could you put together a reference OPTIONS operation for an ajax preflight request?

Problem with newer swagger-node-runner

I am not sure where to report this. I tried to update to the latest version of the swagger express mw, to try to resolve problems with validation errors having status 500. But then all my endpoints ended up returning 404.

Tried the simplest setup I can think of - using swagger generator, and it still failed.
Here are the steps to reproduce:
$ swagger project create hello-world
(choose express)
edit package.json and change MW version to:
"swagger-express-mw": "apigee-127/swagger-express#fcc8541c9af0fefc08c0c14d8c546c0d8e95e65c"
$ npm install
The version of swagger-node-runner is "0.6.13"
$ mocha test --recursive
OR
Test manually with swagger editor.

This is the error that is returned:
TypeError: Cannot read property 'name' of undefined

@types/swagger-express-mw vulnerabilities

req.swagger.params not defined

The latest version of swagger-express-mw no longer defines the req.swagger.params object. This was not an issue with version 0.1.0, which I was on before.

I also noticed that running swagger project install still installs version 0.1.0 of this software.

Error when using new "flattened" node_modules

When using the new "flattened" node_modules architecture my app throws the following error:
[TypeError: Cannot assign to read only property 'swagger' of [object Object]]
when instantiation SwaggerExpress

If I install the dependencies with npm install --legacy-bundling the app works perfectly.

Node.JS version 5.7.0 and 5.11.0 both exhibit this behavior.

How to setup swagger middleware for testing in mocha with supertest

I've been having trouble setting swagger param parser so that I can make unit tests for various controllers. I was originally using a light weight express server with the body-parser package that seem to be working until I figured out swagger-express doesn't place the req.params in the same spots as express does. One way to get this to work would be to place stub properties on the req object and keep using express, but I don't like this method. I feel using swagger-express-mw to parse the params would ensure that I don't encounter any other differences between the way swagger-express-mw/(sway) handles things and the express way of doing things (which is how I assumed it should work).

I would appreciate any help or advice on setting up the middleware in various configurations for testing.

404 Error with 0.7.0 which does not appear with 0.1.0

My current stack is swagger-node with aws-serverless-express to be able to deploy the complete rest-api to one aws lambda function. (reproduce stack from here: ashiina/lambda-local#69 (comment)).

Now as discussed in another Thread by swagger project create hello-world it does automatically use 0.1.0 of swagger-express-mw. So I updated manually to 0.7.0 and added -swagger_params_parser
to my config/default.yaml. Now it does work but the only thing is that I get a 404 for the first lambda invocation and from the 2nd invocation onwards it works as expected. If the function sleeps for long time a cold start is done and the first invocation is again a 404 (error described here: http://stackoverflow.com/questions/42190508/aws-api-gateway-cannot-get-when-function-sleeped-for-long-time).

Do you have any ideas why this does not happen with version 0.1.0 but only with 0.7.0?
(I just realised that it comes from this module because I generated a new minimal test project and there it worked with 0.1.0, but I prefer to use 0.7.0 as there is usage of Sway, which replaces swagger-tools as I understood)

Support for Swagger 3.0?

The Swagger 3.0 spec was released back in July source, but the README.md for swagger-tools (latest release: 0.10.1) states support only for 1.2 and 2.0.

What is your timeline for 'officially' supporting Swagger 3.0?

Unclear whether maintainers are the same, so I posted an identical issue in apigee-127/swagger-tools#529

how to "deny" extra elements on request through the schema

using swagger-express-mw, and having a following yaml:

 /api/applications:
    x-swagger-router-controller: "applications"
    post:
      operationId: "create"
      consumes:
        - "application/json;"
      produces:
       - "application/json"
      parameters:
      - name: "body"
        in: "body"
        description: "initial application data"
        schema:
          title: NewApp
          type: object
          required:
            - "email"
            - "phoneNumber"
          properties:
            phoneNumber:
              type: "string"
            email:
              type: "string"

How do I define that additional elements are not allowed. I.e. I want to prevent posting of:

{
   "email":"bla",
   "phoneNumber":"otherbla",
   "dont": {"want":"this to pass validation"}
}

In general, I'd like to be able to enforce this for some paths, but not for others.

Cheers

req.swagger.params is undefined for path variables

Swagger file:

 /donkeys/{name}:
    x-swagger-router-controller: donkeyController
    get:
      description: Gets a donkey by name
      operationId: getDonkey
      parameters:
        - name: name
          in: path
          description: Donkey Name
          required: true
          type: string          
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/DonkeyResponse"           
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"

donkeyController.js:

function getDonkey(req, res) {
    'use strict';
    var donkeyName = req.swagger.params.name.value;
...

Error:

TypeError: Cannot read property 'name' of undefined

This used to work with version 0.1.0, but after upgrading to 0.6.0, it suddenly broke 👎

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.