ceejayoz
ceejayoz

Reputation: 179994

Representing a static response in Swagger

For certain operations, our API responds with static bits of JSON, for example:

{"status":"ok"}

The closest I've come to making a model definition for this is:

definitions:
  OKMessage:
    type: object
    properties:
      status:
        type: string
        enum: ['ok']

but it feels like there should be a more straightforward way of representing a static string in a model (and results in clearer docs). Is there something in the spec I'm missing?

Upvotes: 1

Views: 1196

Answers (1)

William Cheng
William Cheng

Reputation: 10797

I think that's the correct way to define the response. You may consider using just string (not enum) to give you flexibility in adding different values (e.g. error, processing, etc) in the future.

Upvotes: 1

Related Questions