Can't resolve configured handler swagger-router: movie_get

I am using Swagger with NodeJS and when I test the example I get this error .

Here is my YAML:

swagger: "2.0"
info:
  version: "0.0.1"
  title: Hello World App
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths 
basePath: /
# 
schemes:
  # tip: remove http to make production-grade
  - http
  - https
# format of bodies a client can send (Content-Type)
consumes:
  - application/json
# format of the responses to the client (Accepts)
produces:
  - application/json
paths:
  /movie:
    # our controller name
    x-swagger-router-controller: movie
    get:
      description: get the movies list
      # define the type of response for Success "200" and Error
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GetMoviesListResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
  /swagger:
    x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
  GetMoviesListResponse:
    required:
      - movies
    properties:
      # The array of movies
      movies:
        type: array
        items: 
          type: object
          properties:
            id:
              type: string
            title:
              type: string
            year:
              type: number
  ErrorResponse:
    required:
      - message
    properties:
      message:
        type: string

      

+3


source to share


1 answer


Given your YAML, and assuming you are using swagger-tools with the parameters given in their tutorials, it x-swagger-router-controller: movie

will route any requests for a GET /movie

function get

exported from a module /controllers/movie.js

to your project. Have you installed this?



Also check your swagger options to check if the correct controller path is included, eg. controllers: `${__dirname}`/controllers

...

0


source







All Articles