Class: FtrRuby::OpenAPI
- Inherits:
-
Object
- Object
- FtrRuby::OpenAPI
- Defined in:
- lib/openapi.rb
Instance Attribute Summary collapse
-
#basePath ⇒ Object
Returns the value of attribute basePath.
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#description ⇒ Object
Returns the value of attribute description.
-
#developer_ORCiD ⇒ Object
Returns the value of attribute developer_ORCiD.
-
#email ⇒ Object
Returns the value of attribute email.
-
#endpointpath ⇒ Object
Returns the value of attribute endpointpath.
-
#host ⇒ Object
Returns the value of attribute host.
-
#indicator ⇒ Object
Returns the value of attribute indicator.
-
#metric ⇒ Object
Returns the value of attribute metric.
-
#org_url ⇒ Object
Returns the value of attribute org_url.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#path ⇒ Object
Returns the value of attribute path.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#response_description ⇒ Object
Returns the value of attribute response_description.
-
#responsible_developer ⇒ Object
Returns the value of attribute responsible_developer.
-
#schemas ⇒ Object
Returns the value of attribute schemas.
-
#testid ⇒ Object
Returns the value of attribute testid.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #get_api ⇒ Object
-
#initialize(meta:) ⇒ OpenAPI
constructor
A new instance of OpenAPI.
Constructor Details
#initialize(meta:) ⇒ OpenAPI
Returns a new instance of OpenAPI.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openapi.rb', line 8 def initialize(meta:) indics = [[:indicators]] unless [:indicators].is_a? Array @testid = [:testid] @title = [:testname] @version = [:testversion] @metric = [:metric] @description = [:description] @indicator = indics.first @organization = [:organization] @org_url = [:org_url] @responsible_developer = [:responsible_developer] @email = [:email] @creator = [:creator] @host = [:host] @host = @host.gsub(%r{/$}, "") # remove trailing slash if present @protocol = [:protocol].gsub(%r{[:/]}, "") @basePath = [:basePath].gsub(%r{[:/]}, "") @basePath = "/#{basePath}" unless basePath[0] == "/" # must start with a slash # @path = meta[:path] @response_description = [:response_description] @schemas = [:schemas] @endpointpath = "assess/test" # @end_url = "#{protocol}://#{host}#{basePath}/#{endpointpath}/#{testid}" # basepath starts with / end |
Instance Attribute Details
#basePath ⇒ Object
Returns the value of attribute basePath.
3 4 5 |
# File 'lib/openapi.rb', line 3 def basePath @basePath end |
#creator ⇒ Object
Returns the value of attribute creator.
3 4 5 |
# File 'lib/openapi.rb', line 3 def creator @creator end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/openapi.rb', line 3 def description @description end |
#developer_ORCiD ⇒ Object
Returns the value of attribute developer_ORCiD.
3 4 5 |
# File 'lib/openapi.rb', line 3 def developer_ORCiD @developer_ORCiD end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/openapi.rb', line 3 def email @email end |
#endpointpath ⇒ Object
Returns the value of attribute endpointpath.
3 4 5 |
# File 'lib/openapi.rb', line 3 def endpointpath @endpointpath end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/openapi.rb', line 3 def host @host end |
#indicator ⇒ Object
Returns the value of attribute indicator.
3 4 5 |
# File 'lib/openapi.rb', line 3 def indicator @indicator end |
#metric ⇒ Object
Returns the value of attribute metric.
3 4 5 |
# File 'lib/openapi.rb', line 3 def metric @metric end |
#org_url ⇒ Object
Returns the value of attribute org_url.
3 4 5 |
# File 'lib/openapi.rb', line 3 def org_url @org_url end |
#organization ⇒ Object
Returns the value of attribute organization.
3 4 5 |
# File 'lib/openapi.rb', line 3 def organization @organization end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/openapi.rb', line 3 def path @path end |
#protocol ⇒ Object
Returns the value of attribute protocol.
3 4 5 |
# File 'lib/openapi.rb', line 3 def protocol @protocol end |
#response_description ⇒ Object
Returns the value of attribute response_description.
3 4 5 |
# File 'lib/openapi.rb', line 3 def response_description @response_description end |
#responsible_developer ⇒ Object
Returns the value of attribute responsible_developer.
3 4 5 |
# File 'lib/openapi.rb', line 3 def responsible_developer @responsible_developer end |
#schemas ⇒ Object
Returns the value of attribute schemas.
3 4 5 |
# File 'lib/openapi.rb', line 3 def schemas @schemas end |
#testid ⇒ Object
Returns the value of attribute testid.
3 4 5 |
# File 'lib/openapi.rb', line 3 def testid @testid end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/openapi.rb', line 3 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/openapi.rb', line 3 def version @version end |
Instance Method Details
#get_api ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/openapi.rb', line 33 def get_api <<~"EOF_EOF" openapi: 3.0.0 info: version: "#{version}" title: "#{title}" x-tests_metric: "#{metric}" description: >- #{description} x-applies_to_principle: "#{indicator}" contact: x-organization: "#{organization}" url: "#{org_url}" name: "#{responsible_developer}" x-role: responsible developer email: "#{email}" x-id: "#{creator}" paths: "/#{testid}": post: requestBody: content: application/json: schema: $ref: "#/components/schemas/schemas" required: true responses: "200": description: >- #{response_description} servers: - url: "#{protocol}://#{host}#{basePath}/#{endpointpath}" components: schemas: schemas: required: - resource_identifier properties: resource_identifier: type: string description: the GUID being tested EOF_EOF end |