0

I'm facing a little problem using Swagger UI and I'm not sure yet wheter is it a bug or not...

I've described my API using Swagger Editor and I have a method that contains an enum parameter.

Now, the problem: in the Swagger-UI documentation generated, in the 'model' tab, I have an empty definition of the 'messageType' object :( I want to display the allowed values (BRAND, VISITOR, COMMENT and RESPONSE)

A code snippet to reproduce:

swagger: '2.0'
info:
  version: 1.0.0-SNAPSHOT
  title: foo
  description: foo
host: dev.fr
basePath: /base
schemes:
  - http
  - https
consumes:
  - application/json
produces:
  - application/json

paths:
  /social/message:
    post:
      operationId: create
      responses:
        '201':
          schema:
            $ref: '#/definitions/message'
        'default':
          description: Default error response

definitions:
  message:
    required:
      - title
      - messageType
    properties:
      title:
        type: string
      messageType:
        $ref: '#/definitions/messageType'

  messageType:
    enum:
      - COMMENT
      - RESPONSE

screen capture

Any idea ? I am doing it wrong ? Is it a bug ? Many thanks :)

2
  • 2
    Your messageType doesn't declare it's type. enum is not a valid type in JSON schema. Consider adding type: string as a sibling to the enum. Commented May 31, 2016 at 19:33
  • You're ritght ! Thanks :) Commented Jun 1, 2016 at 12:27

1 Answer 1

1

fehguy is right, problem solved by adding "type: string" on my object :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.