Skip to content

Responsebody of BadRequest (and other errors) #3021

@Baklap4

Description

@Baklap4

when trying to get the users and do supply a wrong api-version in the header it always just returns Bad Request and not showing the response body..

The json of the response body should've been:

{
    "code":400,
    "message":"BadRequest: The HTTP resource that matches the request URI 'http://localhost:30002/users' does not support the API version '1.3'.",
    "meta":{
        "apiVersion":[
            "1.3"
        ]
    }
}

When i'm running the request with Curl it does give me the desired output.

When reporting an issue, please provide the following details:

swagger-ui version

Using version: 3.0.8

Swagger file:

swagger: '2.0'
info:
  title:  Development
  description: Api 
  version: "1.0"

###############################################
# General information                         #
###############################################
host: localhost:30002
basePath: /
schemes:
  - http
produces:
  - application/json
consumes:
  - application/json
tags:
  - name: users
    description: Operations for users

###############################################
# Security                                    #
###############################################
securityDefinitions:
  implicit:
    type: oauth2
    description: Secure access using implicit grant
    flow: implicit
    authorizationUrl: http://localhost:30001/connect/authorize
    scopes:
      api: Full access to all resources
  authorizationCode:
    type: oauth2
    description: Secure access using authorization grant flow
    flow: accessCode
    authorizationUrl: http://localhost:30001/connect/authorize
    tokenUrl: http://localhost:30001/connect/token
    scopes:
      api: Full access to all resources
security:
  - implicit:
    - api
  - authorizationCode:
    - api
  

###############################################
# Parameters                                  #
###############################################
parameters:
  apiVersion:
    in: header
    name: api-version
    type: string
    format: string
    description: Api version to use
    required: false
    default: '1.0'
###############################################
# Responses                                   #
###############################################
responses:
  error:
    description: An error has occured while handling the request. Check the content of the message for the error details.
    schema:
      $ref: '#/definitions/error'
###############################################
# Definitions                                 #
###############################################
definitions:
  user:
    type: object
    description: Defines a user. This can be a driver, backoffice employee, etc.
    properties:
      id:
        type: integer
        format: int32
        description: Uniquely identifies the user.
      key:
        type: string
        description: Uniquely identifies the user to the ERP system.
      name:
        type: string
        description: The display name of the user.
      email:
        type: string
        description: The e-mail address of the user.
  error:
    type: object
    description: Describes the error that occured during the request.
    properties:
      code:
        type: string
        description: The error code that occured.
      message:
        type: string
        description: A user readable message that describes the error in detail for the developer.
      meta:
        type: object
        description: |
          Contains more information about the error message. For example when a validation error occurs, this field describes the fields that were invalid and the validation error that occured. The content of this object can vary based on the type of error.
    required:
      - code
      - message

###############################################
# Paths                                       #
###############################################
paths:
  /users:
    parameters:
        - $ref: '#/parameters/apiVersion'
    get:
      tags:
        - users
      summary: Get all the available users.
      description: Returns all the available users connected to the company.
      responses:
        200:
          description: Successful.
          schema:
            type: array
            items:
              $ref: '#/definitions/user'  
        default:
          $ref: '#/responses/error'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions