Module: OasRails::Builders::EsquemaBuilder

Defined in:
lib/oas_rails/builders/esquema_builder.rb

Class Method Summary collapse

Class Method Details

.build_incoming_schema(klass:, model_to_schema_class: Esquema) ⇒ Hash

Builds a schema for a class when it is used as incoming API data.

Parameters:

  • klass (Class)

    The class for which the schema is built.

Returns:

  • (Hash)

    The schema as a JSON-compatible hash.



9
10
11
12
13
14
# File 'lib/oas_rails/builders/esquema_builder.rb', line 9

def build_incoming_schema(klass:, model_to_schema_class: Esquema)
  configure_common_settings
  model_to_schema_class.configuration.excluded_columns = OasRails.config.excluded_columns_incoming

  model_to_schema_class::Builder.new(klass).build_schema.as_json
end

.build_outgoing_schema(klass:, model_to_schema_class: Esquema) ⇒ Hash

Builds a schema for a class when it is used as outgoing API data.

Parameters:

  • klass (Class)

    The class for which the schema is built.

Returns:

  • (Hash)

    The schema as a JSON-compatible hash.



20
21
22
23
24
25
# File 'lib/oas_rails/builders/esquema_builder.rb', line 20

def build_outgoing_schema(klass:, model_to_schema_class: Esquema)
  configure_common_settings
  model_to_schema_class.configuration.excluded_columns = OasRails.config.excluded_columns_outgoing

  model_to_schema_class::Builder.new(klass).build_schema.as_json
end