I'm using Apigee 127 on top of swagger to create a REST API.
This is the head of the configuration file swagger.yaml
:
swagger: 2.0
info:
version: "0.0.1"
title: LMS API Gateway
# during dev, should point to your local machine
host: localhost
# 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
x-a127-config: {}
x-volos-resources: {}
paths:
/lms/oauth2/token:
# binds a127 app logic to a route
x-swagger-router-controller: authentication
x-volos-authorizations: {}
x-volos-apply: {}
post:
description: Authenticates a user
operationId: authenticate
parameters:
- name: body
in: body
description: The JSON request body
required: true
schema:
$ref: AuthenticationRequest
responses:
"200":
description: Success
schema:
$ref: AuthenticationResponseSuccess
default:
description: Error
schema:
$ref: AuthenticationResponseError
Then I have this AuthenticationRequest
Schema Object that describes how the request body for authentication should be. So far so good.
When I make a valid request, It's working fine, but when I make an invalid one, I get the following response:
HTTP/1.1 500 Internal Server Error
X-Powered-By: Express
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 60
Date: Mon, 06 Oct 2014 16:31:08 GMT
Connection: keep-alive
Parameter (body) is not a valid AuthenticationRequest model
There would be no problem with that if my API spec did not specify that I MUST return a 400 Bad Request
response code for an invalid request (which by the way makes more sense).
So the problem is that I couldn't find a way to change this behaviour in Swagger docs.
Anyone?