Class: OdataDuty::OAS2::IndividualPatchPath
- Inherits:
-
Object
- Object
- OdataDuty::OAS2::IndividualPatchPath
- Defined in:
- lib/odata_duty/oas2/individual_patch_path.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(entity_set) ⇒ IndividualPatchPath
constructor
A new instance of IndividualPatchPath.
- #operation_id ⇒ Object
- #parameters ⇒ Object
- #produces ⇒ Object
- #responses ⇒ Object
Constructor Details
#initialize(entity_set) ⇒ IndividualPatchPath
Returns a new instance of IndividualPatchPath.
21 22 23 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 21 def initialize(entity_set) @entity_set = entity_set end |
Class Method Details
.request_body_definition(entity_set) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 14 def self.request_body_definition(entity_set) writable = entity_set.entity_type.properties.select(&:settable_on_update?) definition = { 'type' => 'object', 'properties' => writable.to_h { |p| [p.name.to_s, p.to_oas2] } } ["#{entity_set.entity_type.name}Update", definition] end |
.to_oas2(entity_set) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 4 def self.to_oas2(entity_set) path_info = new(entity_set) { 'operationId' => path_info.operation_id, 'produces' => path_info.produces, 'parameters' => path_info.parameters, 'responses' => path_info.responses } end |
Instance Method Details
#operation_id ⇒ Object
25 26 27 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 25 def operation_id "Update#{@entity_set.name}" end |
#parameters ⇒ Object
33 34 35 36 37 38 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 33 def parameters [ { 'name' => 'id', 'in' => 'path', 'required' => true, 'type' => id_type }, { 'name' => 'body', 'in' => 'body', 'required' => true, 'schema' => update_schema } ] end |
#produces ⇒ Object
29 30 31 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 29 def produces ['application/json'] end |
#responses ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/odata_duty/oas2/individual_patch_path.rb', line 40 def responses { '200' => { 'description' => 'Success', 'schema' => entity_type_schema }, 'default' => { 'description' => 'Unexpected error', 'schema' => { '$ref' => '#/definitions/Error' } } } end |