open_api 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/Rakefile +1 -0
- data/lib/open_api/components.rb +14 -0
- data/lib/open_api/data_types.rb +27 -0
- data/lib/open_api/path_item.rb +2 -2
- data/lib/open_api/paths.rb +1 -1
- data/lib/open_api/responses.rb +1 -1
- data/lib/open_api/schema.rb +2 -2
- data/lib/open_api/version.rb +1 -1
- data/lib/open_api.rb +1 -0
- data/open_api.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb0adf2485d861c6548d554e3fb7b2f84b53416ff6f09c6af97ffb6b073a247e
|
4
|
+
data.tar.gz: 4df4e9890e7ead39fa4b24b60ec0b25fa05d8ffb3ac7f57ebd3341597e40ce5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a7df0a7d7e84129a3aeafdd14bb318731e8472185622f15f3aa318124b096026a56bb81b19dacd1ca80de72499c8680afa8265ee0b391dca865dee70f96545
|
7
|
+
data.tar.gz: 926ebda0ae134f4a7b9bf29dc8c287283d093d5e10f45cda05e52d3ab0d05bdbf0046ceca84a6380efe8d5a4fa8c7ab8089791377b1d4e4d8bb887edc821b826
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
* Add `#serializable_hash` to Components
|
3
|
+
* Allow Paths and Responses to set like a hash
|
4
|
+
* Fallback to string when it has no serializable way
|
5
|
+
|
1
6
|
## 0.2.0
|
2
7
|
* Allow Schema to behave like OpenStruct 5a698cf796f0467b726062bcd7c2cf2c20693950
|
3
8
|
* Allow to serialize `schema.properties` fb6f2a0a5d58de7c0bfb113b3a6636a50df7de3d
|
data/README.md
CHANGED
@@ -71,7 +71,7 @@ spec = OpenApi::Serializers::YamlSerializer.deserialize(yaml)
|
|
71
71
|
|
72
72
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
73
|
|
74
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version,
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `bundle exec rake bump:patch` to update the version, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
75
|
|
76
76
|
## Contributing
|
77
77
|
|
data/Rakefile
CHANGED
data/lib/open_api/components.rb
CHANGED
@@ -16,6 +16,20 @@ module OpenApi
|
|
16
16
|
self.callbacks = callbacks
|
17
17
|
end
|
18
18
|
|
19
|
+
def serializable_hash
|
20
|
+
{
|
21
|
+
"schemas" => schemas&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
22
|
+
"responses" => responses&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
23
|
+
"parameters" => parameters&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
24
|
+
"examples" => examples&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
25
|
+
"requestBodies" => request_bodies&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
26
|
+
"headers" => headers&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
27
|
+
"securitySchemes" => security_schemes&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
28
|
+
"links" => links&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
29
|
+
"callbacks" => callbacks&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h,
|
30
|
+
}.compact
|
31
|
+
end
|
32
|
+
|
19
33
|
def self.load(hash)
|
20
34
|
return unless hash
|
21
35
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module OpenApi
|
2
|
+
DataType = Struct.new(:name, :type, :format)
|
3
|
+
|
4
|
+
class DataTypes
|
5
|
+
@data = [
|
6
|
+
DataType.new(:integer, :integer, :int32),
|
7
|
+
DataType.new(:long, :integer, :int64),
|
8
|
+
DataType.new(:float, :number, :float),
|
9
|
+
DataType.new(:double, :number, :double),
|
10
|
+
DataType.new(:string, :string),
|
11
|
+
DataType.new(:byte, :string, :byte),
|
12
|
+
DataType.new(:binary, :string, :binary),
|
13
|
+
DataType.new(:boolean, :boolean),
|
14
|
+
DataType.new(:date, :string, :date),
|
15
|
+
DataType.new(:dateTime, :string, :"date-time"),
|
16
|
+
DataType.new(:password, :string, :password),
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.all
|
20
|
+
@data
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.all_types
|
24
|
+
all.map(&:type).uniq
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/open_api/path_item.rb
CHANGED
@@ -13,7 +13,7 @@ module OpenApi
|
|
13
13
|
self.description = description
|
14
14
|
self.servers = servers
|
15
15
|
self.parameters = parameters
|
16
|
-
self.operations = operations.
|
16
|
+
self.operations = operations.map { |k, v| [k.to_s.underscore.to_sym, v] }.to_h
|
17
17
|
end
|
18
18
|
|
19
19
|
def serializable_hash
|
@@ -23,7 +23,7 @@ module OpenApi
|
|
23
23
|
"description" => description&.to_s,
|
24
24
|
"servers" => servers&.map(&:serializable_hash),
|
25
25
|
"parameters" => parameters&.map(&:serializable_hash),
|
26
|
-
}.merge(operations.map { |k, v| [k.to_s, v.serializable_hash] }.to_h)
|
26
|
+
}.merge(operations.map { |k, v| [k.to_s.underscore, v.serializable_hash] }.to_h)
|
27
27
|
.compact
|
28
28
|
end
|
29
29
|
|
data/lib/open_api/paths.rb
CHANGED
data/lib/open_api/responses.rb
CHANGED
data/lib/open_api/schema.rb
CHANGED
@@ -13,7 +13,7 @@ module OpenApi
|
|
13
13
|
self.external_docs = external_docs
|
14
14
|
self.example = example
|
15
15
|
self.deprecated = deprecated
|
16
|
-
self.other_fields_hash = other_fields_hash
|
16
|
+
self.other_fields_hash = other_fields_hash
|
17
17
|
|
18
18
|
other_fields_hash.keys.each { |name| new_field(name) }
|
19
19
|
end
|
@@ -54,7 +54,7 @@ module OpenApi
|
|
54
54
|
when :items then v.serializable_hash
|
55
55
|
when :properties then v.map { |k, v| [k.to_s, v.serializable_hash] }.to_h
|
56
56
|
else
|
57
|
-
v
|
57
|
+
v.to_s
|
58
58
|
end
|
59
59
|
[k.to_s, value]
|
60
60
|
}.to_h
|
data/lib/open_api/version.rb
CHANGED
data/lib/open_api.rb
CHANGED
data/open_api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kent Nagata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bump
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: It provides PORO of OpenAPI specification. It only support OpenAPI v3.
|
98
112
|
email:
|
99
113
|
- ngtknt@me.com
|
@@ -117,6 +131,7 @@ files:
|
|
117
131
|
- lib/open_api/callback.rb
|
118
132
|
- lib/open_api/components.rb
|
119
133
|
- lib/open_api/contact.rb
|
134
|
+
- lib/open_api/data_types.rb
|
120
135
|
- lib/open_api/discriminator.rb
|
121
136
|
- lib/open_api/encoding.rb
|
122
137
|
- lib/open_api/equatable_as_content.rb
|