Class: Jsapi::Meta::License

Inherits:
Jsapi::Model::Base show all
Includes:
OpenAPI::Extensions
Defined in:
lib/jsapi/meta/license.rb

Overview

Specifies a license.

Instance Method Summary collapse

Methods included from OpenAPI::Extensions

included

Methods inherited from Jsapi::Model::Base

#==, #errors, #initialize, #inspect, model_name, #respond_to_missing?

Constructor Details

This class inherits a constructor from Jsapi::Model::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jsapi::Model::Base

Instance Method Details

#identifierObject

:attr: identifier The SDPX identifier of the license.

Applies to OpenAPI 3.1 and higher.



14
# File 'lib/jsapi/meta/license.rb', line 14

attribute :identifier, String, accessors: %i[reader]

#identifier=(identifier) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
# File 'lib/jsapi/meta/license.rb', line 26

def identifier=(identifier) # :nodoc:
  try_modify_attribute!(:identifier) do
    raise 'identifier and url are mutually exclusive' unless url.nil?

    @identifier = identifier
  end
end

#nameObject

:attr: name The name of the license.



19
# File 'lib/jsapi/meta/license.rb', line 19

attribute :name, String

#to_openapi(version) ⇒ Object

Returns a hash representing the OpenAPI license object.



43
44
45
46
47
48
49
50
51
# File 'lib/jsapi/meta/license.rb', line 43

def to_openapi(version, *)
  version = OpenAPI::Version.from(version)

  with_openapi_extensions(
    name: name,
    identifier: (identifier if version >= OpenAPI::V3_1),
    url: url
  )
end

#urlObject

:attr: url The URL of the license.



24
# File 'lib/jsapi/meta/license.rb', line 24

attribute :url, String, accessors: %i[reader]

#url=(url) ⇒ Object

:nodoc:



34
35
36
37
38
39
40
# File 'lib/jsapi/meta/license.rb', line 34

def url=(url) # :nodoc:
  try_modify_attribute!(:url) do
    raise 'identifier and url are mutually exclusive' unless identifier.nil?

    @url = url
  end
end