Coder Social home page Coder Social logo

Support for parameters in PUT about tsoa HOT 2 CLOSED

lukeautry avatar lukeautry commented on April 28, 2024
Support for parameters in PUT

from tsoa.

Comments (2)

lukeautry avatar lukeautry commented on April 28, 2024

@yannisgu I gave this a shot within the test suite, and from what I can tell it generated both the route and the swagger spec correctly:

@Route('PutTest')
export class PutTestController {

  @Put('{id}')
  public async putWithQueryAndModel(id: number, model: TestModel): Promise<TestModel> {
    return new ModelService().getModel();
  }
}
"/PutTest/{id}": {
            "put": {
                "operationId": "putWithQueryAndModel",
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "examples": {},
                        "schema": {
                            "$ref": "#/definitions/TestModel"
                        }
                    }
                },
                "description": "",
                "parameters": [
                    {
                        "description": "",
                        "in": "path",
                        "name": "id",
                        "required": true,
                        "type": "integer"
                    },
                    {
                        "description": "",
                        "in": "body",
                        "name": "model",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/TestModel"
                        }
                    }
                ]
            }
        }
app.put('/PutTest/:id', function(req: any, res: any, next: any) {
    const params = {
      'id': { typeName: 'number', required: true },
      'model': { typeName: 'TestModel', required: true },
    };

    let validatedParams: any[] = [];
    try {
      validatedParams = getValidatedParams(params, req, 'model');
    } catch (err) {
      return next(err);
    }

    const controller = new PutTestController();
    promiseHandler(controller.putWithQueryAndModel.apply(controller, validatedParams), res, next);
  });

Could just simply be a problem with swagger UI?

from tsoa.

yannisgu avatar yannisgu commented on April 28, 2024

Hey @lukeautry

Thanks for your response.
I retried it and everything works as I excpect. I have no idea what is different now...

Sorry for the noise

from tsoa.

Related Issues (20)

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.