Swagger Codegen - Unexpected missing property for name response - node.js

I am trying to generate node.js-server stub using codegen. I have downloaded the swagger-codegen-cli-2.3.1.jar file and am trying to generate the code using cli command.
However, it is failing with the following error message:
[main] ERROR io.swagger.codegen.DefaultCodegen - unexpected missing property for name response
[main] WARN io.swagger.codegen.DefaultCodegen - skipping invalid array property {
"baseName" : "response",
"getter" : "getResponse",
....
"isReadOnly" : false,
"vendorExtensions" : { },
"hasValidation" : false,
"isXmlAttribute" : false,
"isXmlWrapped" : false
}
[main] ERROR io.swagger.codegen.DefaultCodegen - unexpected missing property for name response
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: Tag {
name: messages
description: Messages for blue instance
externalDocs: null
extensions:{}}
Operation: listMessages
Resource: get /instances/{instanceId}/messages
Definitions: {message-common=io.swagger.models.ModelImpl#e68ed4e0, Error Response=io.swagger.models.ModelImpl#7bcf5e6c}
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:932)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:808)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:431)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:746)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
... 5 more
Here is an excerpt from my swagger definitions file.
I did adding/removing x-swagger-router-controller attribute, but that did not help either.
swagger: '2.0'
info:
title: Messages API
version: '1.0'
description: |-
Call used to get messages
host: 'localhost:8080'
paths:
'/instances/{instanceId}/messages':
get:
summary: Get all messages
operationId: listMessages
responses:
'200':
description: 'Success Response'
schema:
type: array
items:
title: Message Output
description: The properties that are included
allOf:
- type: object
properties:
id:
type: string
- title: Message Common
description: The properties that are shared
type: object
properties:
message:
type: string
description: Operation the system must do
details:
type: string
description: 'Textual data'
required:
- message
- details
'401':
description: Unauthorized requests
schema:
type: object
title: Error Response
description: Standard error message.
properties:
errors:
type: array
items:
type: object
properties:
code:
type: string
description: Human readable category
message:
type: string
description: Detailed error message
required:
- code
- message
required:
- errors
'500':
description: Response for other issues
schema:
type: object
title: Error Response
description: Standard error message.
properties:
errors:
type: array
items:
type: object
properties:
code:
type: string
description: Human readable category
message:
type: string
description: Detailed error message
required:
- code
- message
required:
- errors
description: 'Call used to get messages, notices, and/or instructions from E&E system for the product to take. '
parameters:
- name: Digest
in: header
type: string
description: The digest for the body being passed
tags:
- messages
parameters:
- name: instanceId
in: path
type: string
required: true
description: The specific instance for which the message is relevant
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
tags:
- name: messages
description: Messages for instance
Please help. Not sure what I am missing here.

It looks like the error is caused by inline models in responses. While this is perfectly valid, it might be that Swagger Codegen does not support this. You can open an issue in the Swagger Codegen repository.
Try putting the model definitions in the global definitions section, so that your responses section looks like this:
responses:
'200':
description: 'Success Response'
schema:
type: array
items:
$ref: '#/definitions/Message'
'401':
description: Unauthorized requests
schema:
$ref: '#/definitions/Error'
'500':
description: Response for other issues
schema:
$ref: '#/definitions/Error'

Related

express-openapi-validator: ERROR: TypeError: Cannot read property 'schema' of undefined

I have a openapi schema definition like this:
openapi: 3.0.0
info:
title: Manual Handling
description: API documentation for manual handling.
version: 0.1.9
servers:
- url: /
description: Self
- url: http://localhost:3010
description: local
- url: https://zz.zzz.in
description: Development server
paths:
/api/v1/meeting/{meetingId}:
get:
description: Get meeting details by meeting id
summary: Get meeting details by meeting id
tags:
- Meeting
parameters:
- name: meetingId
in: path
required: true
description: Meeting id
schema:
$ref: '#/components/parameters/MeetingId'
responses:
'200':
description: Meeting token obtained successfully
content:
application/json:
schema:
$ref: '#/components/parameters/MeetingId'
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
parameters:
MeetingId:
name: meetingId
description: Meeting id of the session
required: true
in: path
example: 01701deb-34cb-46c2-972d-6eeea3850342
schema:
type: string
and enabled validator for request
new OpenApiValidator({
apiSpec: spec,
validateRequests: true,
}).installSync(app);
and called /api/v1/meeting/{meetingId} api. Instead of it doing a validation it throws an error
ERROR: TypeError: Cannot read property 'schema' of undefined
at dereferenceSchema (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/parsers/util.js:47:24)
at Object.normalizeParameter (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/parsers/util.js:23:18)
at /Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.parse.js:32:45
at Array.forEach (<anonymous>)
at ParametersSchemaParser.parse (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.parse.js:28:20)
at RequestValidator.buildMiddleware (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/openapi.request.validator.js:57:41)
at RequestValidator.validate (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/openapi.request.validator.js:48:37)
at requestValidationHandler (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/index.js:158:79)
at Layer.handle [as handle_request] (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express/lib/router/index.js:317:13)
at /Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express/lib/router/index.js:335:12)
at next (/Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express/lib/router/index.js:275:10)
at /Users/nikhilcm/nikhil/projects/manual_handling_backend/node_modules/express-openapi-validator/dist/middlewares/openapi.security.js:59:17
The documentation is verified in swagger editor, no errors were shown.
Raised the issue in their github page as well.
The problem is here:
parameters:
- name: meetingId
in: path
required: true
description: Meeting id
schema:
$ref: '#/components/parameters/MeetingId' # <-------
schema can only reference schema components (i.e. #/components/schemas/...) and cannot reference parameters (i.e. #/components/parameters/...). Parameter components are supposed to be referenced from the parameter list.
Replace this part with either
1)
parameters:
- $ref: '#/components/parameters/MeetingId'
or
parameters:
- name: meetingId
in: path
required: true
description: Meeting id of the session
example: 01701deb-34cb-46c2-972d-6eeea3850342
schema:
type: string
In this case also remove the (unused) parameter definition from the components/parameters section.

OpenApi 3.0.2. Spec-file does not have router property

I'm trying to build an API using OpenApi 3.0.2 for active documentation. I've managed to build a validated spec-file, and if I take out all of the OpenApi "stuff" from the API itself, all of the routes work properly, and I have no errors (unless I've managed to change something vital while attempting to solve this problem).
Additionally, my controllers do in fact have the generic controller names that this error suggests I use, so my initial thought was that it's having trouble finding my controllers. However, when I used Swagger 2.0 (before rebuilding it with 3.0), I didn't have this problem.
All of my controllers are structured similarly, and when I changed the order of the controllers (path '/users' first), I retrieved the same error ('users' swapped out for 'garments' in the error log).
That said, I feel that there must be something I'm doing wrong in my "bringing together" of the functioning API and the valid spec-file.
I've been looking for a solution to this problem for a while now, but I have found nothing. If this question has been asked and answered before, I apologize; please redirect me. This is my first StackOverflow question, so please be gentle. If I have missed any information important to the question, please let me know.
Error:
outfittr | 2019-01-21T13:51:37.150Z info: Valid specification file
outfittr | 2019-01-21T13:51:37.162Z info: Specification file dereferenced
outfittr | 2019-01-21T13:51:37.210Z info: No localhost or relative server found in spec file, added for testing in Swagger UI
outfittr | 2019-01-21T13:51:37.210Z debug: Register: GET - /garments
outfittr | 2019-01-21T13:51:37.211Z debug: GET - /garments
outfittr | 2019-01-21T13:51:37.212Z debug: Spec-file does not have router property -> try generic controller name: garmentsController
outfittr | 2019-01-21T13:51:37.212Z debug: Controller with generic controller name wasn't found either -> try Default one
outfittr | 2019-01-21T13:51:37.212Z error: There is no controller for GET - /garments
outfittr exited with code 0
openapi.yaml:
openapi: 3.0.2
info:
version: "1.0.0"
title: Outfittr API
paths:
/swagger:
x-swagger-pipe: swagger_raw
####################################### Garments ##############################################
/garments:
x-router-controller: garmentsController
get:
description: Returns an array of garments.
operationId: indexGarments
responses:
"200":
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new garment
operationId: newGarment
description: Adds garment to the system
responses:
'200':
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Garment'
description: User that was created.
/garments/{_id}:
x-router-controller: garmentsController
get:
description: Returns one garment
operationId: viewGarment
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/Garment'
default:
$ref: "#/components/schemas/ErrorResponse"
######################################## Users ################################################
/users:
x-router-controller: usersController
get:
description: Returns an array of users.
operationId: indexUsers
responses:
"200":
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new user
operationId: newUser
description: Adds user to the system
responses:
'200':
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: User that was created.
/users/{_id}:
x-router-controller: usersController
get:
description: Returns one user
operationId: viewUser
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/User'
default:
$ref: "#/components/schemas/ErrorResponse"
####################################### Wardrobe ##############################################
/wardrobe:
x-router-controller: wardrobeController
get:
description: Returns an array of garments in the user's wardrobe.
operationId: indexWardrobeItems
responses:
"200":
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
post:
summary: Creates a new wardrobe item
operationId: newWardrobeItem
description: Adds garment to the user's wardrobe in the system
responses:
'200':
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/WardrobeItem'
description: User that was created.
/wardrobeItem/{_id}:
x-router-controller: wardrobeController
get:
description: Returns one wardrobe item
operationId: viewWardrobeItem
parameters:
- in: path
name: _id
schema:
type: string
required: true
description: Numeric ID of the user to get
responses:
"200":
$ref: '#/components/schemas/WardrobeItem'
default:
$ref: "#/components/schemas/ErrorResponse"
###################################### Components #############################################
servers:
- url: outfittr.net
- url: localhost:3000
components:
schemas:
User:
type: object
required:
- _id
- email
- username
- password
properties:
_id:
type: string
description: unique ID given by Mongo.
firstName:
type: string
description: First name of the user.
lastName:
type: string
description: Last name of the user.
email:
type: string
description: User's email address.
username:
type: string
description: User's username (for login)
password:
type: string
description: User's password (for login).
create_date:
type: string
description: date that the user joined.
__v:
type: integer
description: I have no idea.
Garment:
type: object
required:
- _id
- type
- imageLink
properties:
_id:
type: string
description: unique ID given by Mongo.
type:
type: string
description: type of garment
imageLink:
type: string
description: primary color of garment
__v:
type: integer
description: I have no idea.
WardrobeItem:
type: object
required:
- _id
- owner_id
- garment_id
properties:
_id:
type: string
description: unique ID given by Mongo.
unavailable:
type: boolean
description: Is the wardrobe item dirty, loaned out, or otherwise unavailable?
owner_id:
type: string
description: foreign key linking this wardrobe item to its owner.
garment_id:
type: string
description: foreign key linking this wadrobe item to the garment it is.
torn:
type: boolean
description: Is the wardrobe item torn?
reserveDate:
type: string
description: Optional - a date for which this wardrobe item must be worn
reserveTilDate:
type: string
description: Optional - a date after which the wardrobe item cannot be worn until the reserveDate.
__v:
type: integer
description: I have no idea.
ErrorResponse:
required:
- message
properties:
message:
type: string
Any help is vastly appreciated.
I'll answer this even if it's late because I have had this same problem and looked for a long time the solution. If someone else happens to have any reference on how to fix it.
When you set the controllers parameter in oas-tools:
OasTools.configure({
controllers: `${__dirname}/controllers`,
...
});
The default mapping that oas-tools makes to load the files is endpoint+Controller.js, in your case oas-tools would look for the export function indexGarments in .../controllers/garmentsController.js
Another example would be for the case /garments/{_ id}, the name of the controller file should be garments_idController.js
Using x-router-controller
If you want to use the parameter x-router-controller you have to put it inside the method:
...
/garments:
get:
x-router-controller: garmentsController
operationId: indexGarments
description: Returns an array of garments.
responses:
But be careful because it also modifies the value of the parameter (I do not know if this is a bug or because the name of the files has that requirement), for example, if you configure x-router-controller with the value garments.resource the file to be searched will be .../controllers/garmentsresource.js
In case you set the x-router-controller parameter and the file is not found, this error will be thrown:
info: Valid specification file
info: Specification file dereferenced
debug: Register: GET - /health
debug: GET - /health
debug: OAS-doc has x-router-controller property
error: undefined
For OAS3 you may try this:
paths:
/users:
get:
tags:
- User
x-openapi-router-controller: usersController
description: Returns an array of users.
operationId: indexUsers
responses:
"200":
$ref: '#/components/schemas/User'

swaggerhub and REST API

I use swaggerHub for write the documentation of my new app Node but I have a problem with one api.
My API require two params.
Example : POST http://cloud.amazingwebsite.com/:service/:action
Ok, if you want to use this API, you must to give two values. My problem is that the doc of swaggerHub propose only examples with one param.
Please, do you have a example with two params ? Is it possible ? Thanks
If you do it like this:
"/{service}/{action}":
x-swagger-router-controller: serviceController
post:
summary: To perform an action
operationId: serviceAction
parameters:
- name: service
in: path
required: true
type: string
description: Request Path Param for service
- name: action
in: path
required: true
type: string
description: Request Path Param for Action
responses:
'200':
description: Success
schema:
"$ref": "#/definitions/SuccessResponse"
default:
description: Error
schema:
"$ref": "#/definitions/ErrorResponse"
definitions:
SuccessResponse:
type: object
ErrorResponse:
required:
- error
properties:
error:
type: string

why does my swagger-server generate errors?

I got following errors about the swagger yaml when starting index.js in nodejs-server from "Generate Server" on Swagger Editor.
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1deleteScenario~1/delete/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1stopScenario~1/post/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1restartScenario~1/post/parameters/0: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/2: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/1: Missing required property: $ref
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Not a valid parameter definition
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Not a valid parameter definition
#: Missing required property: schema
#: Missing required property: type
#/paths/~1botManagement~1startScenario~1/post/parameters/0: Missing required property: $ref
yaml file is below.
swagger: "2.0"
info:
description: I wrote something but can't describe it.
version: 1
title: I wrote something but can't describe it.
termOfService: I wrote something but can't describe it.
contact:
email: xxxx#xxxx
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
host: xxxx.xxxx.xxxx.xxxx
basePath: /v1
tags:
- name: I wrote something but can't describe it.
schemes:
- https
paths:
/XXXXXXXXXX:
get:
summary: I wrote something but can't describe it.
description: I wrote something but can't describe it.
responses:
200:
description: Successful response
schema:
type: object
properties:
pid:
type: integer
format: int64
example: 0
name:
type: string
example: sample
pm2_env:
type: object
example: {username:sample, windowsHide:true...}
pm_id:
type: integer
format: int64
example: 0
monit:
type: object
example: {memory:0, cpu:0}
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx:
post:
summary: I wrote something but can't describe it.
description: I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: I wrote something but can't describe it.
404:
description: "API not found"
500:
description: "Internal server error"
/xxxxx/xxxxx/:
post:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx/:
post:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
/xxxxx/xxxxx/:
delete:
summary: I wrote something but can't describe it.
description:
I wrote something but can't describe it.
parameters:
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: true
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
- name: xxxxx
in: formData
description: I wrote something but can't describe it.
required: false
type: string
responses:
200:
description: Successful response
schema:
type: object
properties:
scenario:
type: string
example: sample.js
status:
type: string
example: I wrote something but can't describe it.
400:
description: Bad request
404:
description: API not found
500:
description: Internal server error
It looks the missing property of "$ref".
I know what this property is used. But I don't need any reference to other docs.
In this case, how can I solve this problems?
Your definition has syntax errors.
1) version requires a string value, so it should be version: '1', not version: 1. Without quotes 1 is parsed as a number.
2) example: {username:sample, windowsHide:true...} is not valid YAML, it should be
example:
username: sample
windowsHide: true
or using JSON syntax:
example: {"username": "sample", "windowsHide": true}
Same for other inline object examples.
3) Operations that use in: formData parameters should specify application/x-www-form-urlencoded or multipart/form-data in the consumes keyword:
consumes:
- application/x-www-form-urlencoded
It's hard to say what else might be wrong without seeing your actual definition. You can paste your YAML into https://editor.swagger.io to check for syntax errors, or if your definition has a public URL, use the online validator
http://online.swagger.io/validator/debug?url=YOUR_URL

Cannot resolve the configured swagger-router handler: movie_get

I'm using Swagger with NodeJS, and when I test an example I have 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
Given your YAML, and assuming you're using swagger-tools with the options given in their tutorials, x-swagger-router-controller: movie will route any requests to GET /movie to a function called get exported from the module /controllers/movie.js in your project. Have you set that up?
Also check your swagger options to check that the correct controllers path is included, e.g. controllers: `${__dirname}`/controllers.

Resources