I am currently working on a Swagger documentation for Ruby on Rails API. The API has lots of enumerators (enums) which are included in various models. The enums are stored as hashes and not arrays in the app/models/concerns
directory so that they can be modified without issues later.
State Enum (state.rb)
module State
extend ActiveSupport::Concern
included do
enum state: { state1: 'State 1',
state2: 'State 2',
state3: 'State 3',
state4: 'State 4',
state5: 'State 5' }
end
end
However, when I try to represent this in a component schema in Swagger like this:
components:
schemas:
State:
type: object
properties:
enum: { state1: 'State 1',
state2: 'State 2',
state3: 'State 3',
state4: 'State 4',
state5: 'State 5' }
I get an error:
should not have additional properties
state1: 'State 1'
state2: 'State 2'
state3: 'State 3'
state4: 'State 4'
state5: 'State 5'
I want to represent the enums in hashes and not in arrays. Is there any workaround I can get to make this work?