dry_open_api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/Custom.md +10 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +10 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dry_open_api.gemspec +32 -0
- data/lib/dry_open_api.rb +49 -0
- data/lib/dry_open_api/callback.rb +23 -0
- data/lib/dry_open_api/components.rb +54 -0
- data/lib/dry_open_api/contact.rb +23 -0
- data/lib/dry_open_api/data_types.rb +31 -0
- data/lib/dry_open_api/discriminator.rb +40 -0
- data/lib/dry_open_api/encoding.rb +25 -0
- data/lib/dry_open_api/equatable_as_content.rb +13 -0
- data/lib/dry_open_api/example.rb +24 -0
- data/lib/dry_open_api/external_documentation.rb +20 -0
- data/lib/dry_open_api/header.rb +42 -0
- data/lib/dry_open_api/info.rb +38 -0
- data/lib/dry_open_api/license.rb +20 -0
- data/lib/dry_open_api/link.rb +50 -0
- data/lib/dry_open_api/media_type.rb +35 -0
- data/lib/dry_open_api/o_auth_flow.rb +25 -0
- data/lib/dry_open_api/o_auth_flows.rb +27 -0
- data/lib/dry_open_api/operation.rb +60 -0
- data/lib/dry_open_api/parameter.rb +66 -0
- data/lib/dry_open_api/path_item.rb +42 -0
- data/lib/dry_open_api/paths.rb +26 -0
- data/lib/dry_open_api/reference.rb +21 -0
- data/lib/dry_open_api/request_body.rb +22 -0
- data/lib/dry_open_api/response.rb +55 -0
- data/lib/dry_open_api/responses.rb +37 -0
- data/lib/dry_open_api/schema.rb +107 -0
- data/lib/dry_open_api/security_requirement.rb +20 -0
- data/lib/dry_open_api/security_schema.rb +35 -0
- data/lib/dry_open_api/serializers.rb +7 -0
- data/lib/dry_open_api/serializers/yaml_serializer.rb +17 -0
- data/lib/dry_open_api/server.rb +21 -0
- data/lib/dry_open_api/server_variable.rb +21 -0
- data/lib/dry_open_api/specification.rb +44 -0
- data/lib/dry_open_api/tag.rb +23 -0
- data/lib/dry_open_api/version.rb +3 -0
- data/lib/dry_open_api/xml.rb +26 -0
- metadata +211 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module DryOpenApi
|
|
2
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#security-requirement-object
|
|
3
|
+
class SecurityRequirement
|
|
4
|
+
extend Forwardable
|
|
5
|
+
|
|
6
|
+
def initialize(**hash)
|
|
7
|
+
self.hash = hash.with_indifferent_access
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def_delegator :hash, :[]
|
|
11
|
+
|
|
12
|
+
def self.load(hash)
|
|
13
|
+
new(**hash.symbolize_keys)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
attr_accessor :hash
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#security-scheme-object
|
|
5
|
+
class SecuritySchema
|
|
6
|
+
prepend EquatableAsContent
|
|
7
|
+
extend Dry::Initializer
|
|
8
|
+
|
|
9
|
+
option :type, proc(&:to_s)
|
|
10
|
+
option :name, proc(&:to_s)
|
|
11
|
+
option :in, proc(&:to_s)
|
|
12
|
+
option :scheme, proc(&:to_s)
|
|
13
|
+
option :flows
|
|
14
|
+
option :open_id_connect_url, proc(&:to_s)
|
|
15
|
+
option :bearer_format, proc(&:to_s), default: proc { nil }
|
|
16
|
+
option :description, proc(&:to_s), default: proc { nil }
|
|
17
|
+
|
|
18
|
+
# rubocop:disable Metrics/MethodLength
|
|
19
|
+
def self.load(hash)
|
|
20
|
+
return unless hash
|
|
21
|
+
|
|
22
|
+
new(
|
|
23
|
+
type: hash['type'],
|
|
24
|
+
description: hash['description'],
|
|
25
|
+
name: hash['name'],
|
|
26
|
+
in: hash['in'],
|
|
27
|
+
scheme: hash['scheme'],
|
|
28
|
+
bearer_format: hash['bearerFormat'],
|
|
29
|
+
flows: OAuthFlows.load(hash['flows']),
|
|
30
|
+
open_id_connect_url: hash['openIdConnectUrl']
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
module Serializers
|
|
5
|
+
class YamlSerializer
|
|
6
|
+
def serialize(specification)
|
|
7
|
+
hash = specification.serializable_hash
|
|
8
|
+
YAML.dump(hash)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def deserialize(yaml_string)
|
|
12
|
+
hash = YAML.load(yaml_string)
|
|
13
|
+
Specification.load(hash)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#server-object
|
|
5
|
+
class Server
|
|
6
|
+
prepend EquatableAsContent
|
|
7
|
+
extend Dry::Initializer
|
|
8
|
+
|
|
9
|
+
option :url, proc(&:to_s)
|
|
10
|
+
option :description, proc(&:to_s), default: proc { nil }
|
|
11
|
+
option :variables, default: proc { nil }
|
|
12
|
+
|
|
13
|
+
def self.load(hash)
|
|
14
|
+
new(
|
|
15
|
+
url: hash['url'],
|
|
16
|
+
description: hash['description'],
|
|
17
|
+
variables: hash['variables']&.map { |h| ServerVariable.load(h) }
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#server-variable-object
|
|
5
|
+
class ServerVariable
|
|
6
|
+
prepend EquatableAsContent
|
|
7
|
+
extend Dry::Initializer
|
|
8
|
+
|
|
9
|
+
option :default
|
|
10
|
+
option :enum, default: proc { nil }
|
|
11
|
+
option :description, proc(&:to_s), default: proc { nil }
|
|
12
|
+
|
|
13
|
+
def self.load(hash)
|
|
14
|
+
new(
|
|
15
|
+
enum: hash['enum'],
|
|
16
|
+
default: hash['default'],
|
|
17
|
+
description: hash['description']
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasObject
|
|
5
|
+
class Specification
|
|
6
|
+
prepend EquatableAsContent
|
|
7
|
+
extend Dry::Initializer
|
|
8
|
+
|
|
9
|
+
option :openapi, proc(&:to_s)
|
|
10
|
+
option :info
|
|
11
|
+
option :paths
|
|
12
|
+
option :servers, default: proc { nil }
|
|
13
|
+
option :components, default: proc { nil }
|
|
14
|
+
option :security, default: proc { nil }
|
|
15
|
+
option :tags, default: proc { nil }
|
|
16
|
+
option :external_docs, default: proc { nil }
|
|
17
|
+
|
|
18
|
+
def serializable_hash
|
|
19
|
+
{
|
|
20
|
+
'openapi' => openapi,
|
|
21
|
+
'info' => info.serializable_hash,
|
|
22
|
+
'paths' => paths.serializable_hash,
|
|
23
|
+
'components' => components&.serializable_hash,
|
|
24
|
+
'security' => security&.map(&:serializable_hash),
|
|
25
|
+
'tags' => tags&.map(&:serializable_hash),
|
|
26
|
+
'externalDocs' => external_docs&.serializable_hash
|
|
27
|
+
}.compact
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.load(hash)
|
|
31
|
+
return unless hash
|
|
32
|
+
|
|
33
|
+
new(
|
|
34
|
+
openapi: hash['openapi'],
|
|
35
|
+
info: Info.load(hash['info']),
|
|
36
|
+
paths: Paths.load(hash['paths']),
|
|
37
|
+
components: Components.load(hash['components']),
|
|
38
|
+
security: hash['security']&.map { |requirement_hash| SecurityRequirement.load(requirement_hash) },
|
|
39
|
+
tags: hash['tags']&.map { |tag_hash| Tag.load(tag_hash) },
|
|
40
|
+
external_docs: ExternalDocumentation.load(hash['externalDocs'])
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#tagObject
|
|
5
|
+
class Tag
|
|
6
|
+
prepend EquatableAsContent
|
|
7
|
+
extend Dry::Initializer
|
|
8
|
+
|
|
9
|
+
option :name, proc(&:to_s)
|
|
10
|
+
option :description, proc(&:to_s), default: proc { nil }
|
|
11
|
+
option :external_docs, default: proc { nil }
|
|
12
|
+
|
|
13
|
+
def self.load(hash)
|
|
14
|
+
return unless hash
|
|
15
|
+
|
|
16
|
+
new(
|
|
17
|
+
name: hash['name'],
|
|
18
|
+
description: hash['description'],
|
|
19
|
+
external_docs: ExternalDocumentation.load(hash['externalDocs']),
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'dry-initializer'
|
|
2
|
+
|
|
3
|
+
module DryOpenApi
|
|
4
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#xml-object
|
|
5
|
+
class Xml
|
|
6
|
+
extend Dry::Initializer
|
|
7
|
+
|
|
8
|
+
option :name, proc(&:to_s), default: proc { nil }
|
|
9
|
+
option :namespace, proc(&:to_s), default: proc { nil }
|
|
10
|
+
option :prefix, proc(&:to_s), default: proc { nil }
|
|
11
|
+
option :attribute, default: proc { false }
|
|
12
|
+
option :wrapped, default: proc { false }
|
|
13
|
+
|
|
14
|
+
def self.load(hash)
|
|
15
|
+
return unless hash
|
|
16
|
+
|
|
17
|
+
new(
|
|
18
|
+
name: hash['name'],
|
|
19
|
+
namespace: hash['namespace'],
|
|
20
|
+
prefix: hash['prefix'],
|
|
21
|
+
attribute: hash['attribute'],
|
|
22
|
+
wrapped: hash['wrapped']
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: dry_open_api
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andy Ruck
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activesupport
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '6.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '6.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dry-initializer
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 2.0.2
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 2.0.2
|
|
51
|
+
type: :development
|
|
52
|
+
prerelease: false
|
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - "~>"
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: 2.0.2
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 2.0.2
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: rake
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '10.0'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '10.0'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: rspec
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '3.0'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '3.0'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: pry
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: simplecov
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: bump
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0'
|
|
131
|
+
description: It provides a dried PORO of OpenAPI specification.
|
|
132
|
+
email:
|
|
133
|
+
- devops@talentplatforms.net
|
|
134
|
+
executables: []
|
|
135
|
+
extensions: []
|
|
136
|
+
extra_rdoc_files: []
|
|
137
|
+
files:
|
|
138
|
+
- ".github/ISSUE_TEMPLATE/Custom.md"
|
|
139
|
+
- ".gitignore"
|
|
140
|
+
- ".rubocop.yml"
|
|
141
|
+
- CHANGELOG.md
|
|
142
|
+
- CODE_OF_CONDUCT.md
|
|
143
|
+
- Gemfile
|
|
144
|
+
- Gemfile.lock
|
|
145
|
+
- LICENSE.txt
|
|
146
|
+
- README.md
|
|
147
|
+
- Rakefile
|
|
148
|
+
- bin/console
|
|
149
|
+
- bin/setup
|
|
150
|
+
- dry_open_api.gemspec
|
|
151
|
+
- lib/dry_open_api.rb
|
|
152
|
+
- lib/dry_open_api/callback.rb
|
|
153
|
+
- lib/dry_open_api/components.rb
|
|
154
|
+
- lib/dry_open_api/contact.rb
|
|
155
|
+
- lib/dry_open_api/data_types.rb
|
|
156
|
+
- lib/dry_open_api/discriminator.rb
|
|
157
|
+
- lib/dry_open_api/encoding.rb
|
|
158
|
+
- lib/dry_open_api/equatable_as_content.rb
|
|
159
|
+
- lib/dry_open_api/example.rb
|
|
160
|
+
- lib/dry_open_api/external_documentation.rb
|
|
161
|
+
- lib/dry_open_api/header.rb
|
|
162
|
+
- lib/dry_open_api/info.rb
|
|
163
|
+
- lib/dry_open_api/license.rb
|
|
164
|
+
- lib/dry_open_api/link.rb
|
|
165
|
+
- lib/dry_open_api/media_type.rb
|
|
166
|
+
- lib/dry_open_api/o_auth_flow.rb
|
|
167
|
+
- lib/dry_open_api/o_auth_flows.rb
|
|
168
|
+
- lib/dry_open_api/operation.rb
|
|
169
|
+
- lib/dry_open_api/parameter.rb
|
|
170
|
+
- lib/dry_open_api/path_item.rb
|
|
171
|
+
- lib/dry_open_api/paths.rb
|
|
172
|
+
- lib/dry_open_api/reference.rb
|
|
173
|
+
- lib/dry_open_api/request_body.rb
|
|
174
|
+
- lib/dry_open_api/response.rb
|
|
175
|
+
- lib/dry_open_api/responses.rb
|
|
176
|
+
- lib/dry_open_api/schema.rb
|
|
177
|
+
- lib/dry_open_api/security_requirement.rb
|
|
178
|
+
- lib/dry_open_api/security_schema.rb
|
|
179
|
+
- lib/dry_open_api/serializers.rb
|
|
180
|
+
- lib/dry_open_api/serializers/yaml_serializer.rb
|
|
181
|
+
- lib/dry_open_api/server.rb
|
|
182
|
+
- lib/dry_open_api/server_variable.rb
|
|
183
|
+
- lib/dry_open_api/specification.rb
|
|
184
|
+
- lib/dry_open_api/tag.rb
|
|
185
|
+
- lib/dry_open_api/version.rb
|
|
186
|
+
- lib/dry_open_api/xml.rb
|
|
187
|
+
homepage: https://github.com/talentplatforms/dry_open_api
|
|
188
|
+
licenses:
|
|
189
|
+
- MIT
|
|
190
|
+
metadata: {}
|
|
191
|
+
post_install_message:
|
|
192
|
+
rdoc_options: []
|
|
193
|
+
require_paths:
|
|
194
|
+
- lib
|
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
|
+
requirements:
|
|
197
|
+
- - ">="
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
199
|
+
version: '0'
|
|
200
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
|
+
requirements:
|
|
202
|
+
- - ">="
|
|
203
|
+
- !ruby/object:Gem::Version
|
|
204
|
+
version: '0'
|
|
205
|
+
requirements: []
|
|
206
|
+
rubyforge_project:
|
|
207
|
+
rubygems_version: 2.7.6
|
|
208
|
+
signing_key:
|
|
209
|
+
specification_version: 4
|
|
210
|
+
summary: Dry-PORO OpenAPI 3.x
|
|
211
|
+
test_files: []
|