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.



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

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

#identifier=(identifier) ⇒ Object

:nodoc:



24
25
26
27
28
# File 'lib/jsapi/meta/license.rb', line 24

def identifier=(identifier) # :nodoc:
  raise 'identifier and url are mutually exclusive' if url.present?

  @identifier = identifier
end

#nameObject

:attr: name The name of the license.



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

attribute :name, String

#to_openapi(version) ⇒ Object

Returns a hash representing the OpenAPI license object.



37
38
39
40
41
42
43
44
45
# File 'lib/jsapi/meta/license.rb', line 37

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.



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

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

#url=(url) ⇒ Object

:nodoc:



30
31
32
33
34
# File 'lib/jsapi/meta/license.rb', line 30

def url=(url) # :nodoc:
  raise 'identifier and url are mutually exclusive' if identifier.present?

  @url = url
end