Module: Serega::SeregaPlugins::OpenAPI::ClassMethods

Defined in:
lib/serega/plugins/openapi/openapi.rb

Overview

Serega additional/patched class methods

See Also:

Instance Method Summary collapse

Instance Method Details

#openapi_properties(props = FROZEN_EMPTY_HASH) ⇒ Hash

Adds new OpenAPI properties and returns all properties

Parameters:

  • props (Hash) (defaults to: FROZEN_EMPTY_HASH)

    Specifies new properties

Returns:

  • (Hash)

    Specified OpenAPI properties



202
203
204
# File 'lib/serega/plugins/openapi/openapi.rb', line 202

def openapi_properties(props = FROZEN_EMPTY_HASH)
  config.openapi.properties(props)
end

#openapi_schemaObject

OpenAPI schema for current serializer



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/serega/plugins/openapi/openapi.rb', line 178

def openapi_schema
  properties = SeregaUtils::EnumDeepDup.call(openapi_properties)
  required_properties = []

  attributes.each do |attribute_name, attribute|
    add_openapi_property(properties, attribute_name, attribute)
    add_openapi_required_property(required_properties, attribute_name, attribute)
  end

  {
    type: "object",
    properties: properties,
    required: required_properties,
    additionalProperties: false
  }
end

#openapi_schema_nameString

Builds OpenAPI schema name using configured builder

Returns:

  • (String)

    OpenAPI schema name



211
212
213
# File 'lib/serega/plugins/openapi/openapi.rb', line 211

def openapi_schema_name
  config.openapi.schema_name_builder.call(self)
end