Class: Praxis::Docs::OpenApi::OperationObject
- Inherits:
-
Object
- Object
- Praxis::Docs::OpenApi::OperationObject
- Defined in:
- lib/praxis/docs/open_api/operation_object.rb
Instance Attribute Summary collapse
- #action ⇒ Object readonly
- #id ⇒ Object readonly
- #tags ⇒ Object readonly
- #url ⇒ Object readonly
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(id:, url:, action:, tags:) ⇒ OperationObject
constructor
A new instance of OperationObject.
Constructor Details
#initialize(id:, url:, action:, tags:) ⇒ OperationObject
Returns a new instance of OperationObject.
14 15 16 17 18 19 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 14 def initialize(id:, url:, action:, tags:) @id = id @url = url @action = action @tags = end |
Instance Attribute Details
#action ⇒ Object (readonly)
12 13 14 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 12 def action @action end |
#id ⇒ Object (readonly)
12 13 14 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 12 def id @id end |
#tags ⇒ Object (readonly)
12 13 14 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 12 def @tags end |
#url ⇒ Object (readonly)
12 13 14 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 12 def url @url end |
Instance Method Details
#dump ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/praxis/docs/open_api/operation_object.rb', line 21 def dump all_parameters = ParameterObject.process_parameters(action) = + action.traits h = { summary: action.name.to_s, # externalDocs: {}, # TODO/FIXME operationId: id, responses: ResponsesObject.new(responses: action.responses).dump # callbacks # deprecated: false # security: [{}] # servers: [{}] } # Handle versioning header/params for the action in a special way, by linking to the existing component # spec that will be generated globally api_info = ApiDefinition.instance.infos[action.endpoint_definition.version] if (version_with = api_info.version_with) all_parameters.push('$ref' => '#/components/parameters/ApiVersionHeader') if version_with.include?(:header) all_parameters.push('$ref' => '#/components/parameters/ApiVersionParam') if version_with.include?(:params) end h[:description] = action.description if action.description h[:tags] = .uniq unless .empty? h[:parameters] = all_parameters unless all_parameters.empty? h[:requestBody] = RequestBodyObject.new(attribute: action.payload).dump if action.payload h end |