Class: OdataDuty::OAS2::CollectionGetPath
- Inherits:
-
Struct
- Object
- Struct
- OdataDuty::OAS2::CollectionGetPath
- Defined in:
- lib/odata_duty/oas2/collection_get_path.rb
Constant Summary collapse
- COLLECTION_PARAMETERS =
[ { 'name' => '$filter', 'in' => 'query', 'type' => 'string', 'description' => 'Filter the results, supporting `and` and flat `or` combinations' }, { 'name' => '$search', 'in' => 'query', 'type' => 'string', 'description' => 'Search using structured expressions with AND, OR, NOT operators' }, { 'name' => '$select', 'in' => 'query', 'type' => 'array', 'items' => { 'type' => 'string' }, 'collectionFormat' => 'csv', 'description' => 'Comma-separated list of properties to return' }, { 'name' => '$top', 'in' => 'query', 'type' => 'integer', 'description' => 'Number of results to return' }, { 'name' => '$skip', 'in' => 'query', 'type' => 'integer', 'description' => 'Number of results to skip' }, { 'name' => '$count', 'in' => 'query', 'type' => 'boolean', 'description' => 'Include count of the results' }, { 'name' => '$skiptoken', 'in' => 'query', 'type' => 'string', 'description' => 'Token for next page of results' } ].freeze
- COLLECTION_RESPONSE_DEFAULTS =
{ '@odata.nextLink' => { 'type' => 'string', 'description' => 'Url for next page of results', 'x-nullable' => true }, '@odata.count' => { 'type' => 'integer', 'description' => 'Total count of results, if $count set to true', 'x-nullable' => true } }.freeze
- PARAMETER_REQUIREMENTS =
{ '$top' => :od_top, '$count' => :count, '$skip' => :od_skip, '$skiptoken' => :od_skiptoken, '$search' => :od_search }.freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#entity_set ⇒ Object
Returns the value of attribute entity_set.
Instance Method Summary collapse
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
3 4 5 |
# File 'lib/odata_duty/oas2/collection_get_path.rb', line 3 def context @context end |
#entity_set ⇒ Object
Returns the value of attribute entity_set
3 4 5 |
# File 'lib/odata_duty/oas2/collection_get_path.rb', line 3 def entity_set @entity_set end |
Instance Method Details
#oas2_success_response ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/odata_duty/oas2/collection_get_path.rb', line 85 def oas2_success_response { 'description' => 'Collection Response', 'schema' => { 'type' => 'object', 'properties' => { 'value' => { 'type' => 'array', 'items' => { '$ref' => "#/definitions/#{entity_set.entity_type_name}" } } }.merge(COLLECTION_RESPONSE_DEFAULTS) } } end |
#to_oas2 ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/odata_duty/oas2/collection_get_path.rb', line 71 def to_oas2 instance = entity_set.resolver_class.new(context: context, init_args: entity_set.init_args) parameters = COLLECTION_PARAMETERS.select do |param| !PARAMETER_REQUIREMENTS.key?(param['name']) || instance.respond_to?(PARAMETER_REQUIREMENTS[param['name']]) end { 'operationId' => "GetCollectionOf#{entity_set.name}", 'produces' => ['application/json'], 'parameters' => parameters, 'responses' => { '200' => oas2_success_response, 'default' => DEFAULT_ERROR_RESPONSE } } end |