swagger_yard 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/swagger_yard/type_parser.rb +10 -2
- data/lib/swagger_yard/version.rb +1 -1
- data/lib/swagger_yard.rb +1 -0
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92fee53b6f39a4a44e733619571d5c051054df3e7721058b50d6f18654898d73
|
4
|
+
data.tar.gz: 93e2c4acd9fb8c523a39c916257e41a5c6426e5033439f814223d91397317606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e2f8c39bdaf2a8009dc7f78b4a8f589da25737fa4cb3e77ab89395abe84459a52106d85aa026b533bbefdfe646cfa9c7fc7d9ede512be5edd4e242ada164ba
|
7
|
+
data.tar.gz: b893eddf59099d0fc2cba25486d5e7b2073b2386d3e0805addf7f7d2b280ccdd165038cd5323ab5315ecd8ac7a5ad07b0b6541471c6c14f7ff5890309de313cf
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# SwaggerYard [![Build Status](https://
|
1
|
+
# SwaggerYard [![Build Status](https://github.com/livingsocial/swagger_yard/actions/workflows/rspec.yml/badge.svg)](https://github.com/livingsocial/swagger_yard/actions/workflows/rspec.yml)
|
2
2
|
|
3
3
|
SwaggerYard is a gem to convert custom YARD tags in comments into Swagger 2.0 or OpenAPI 3.0.0 specs.
|
4
4
|
|
@@ -176,6 +176,7 @@ Types of things (parameters or responses of an operation, properties of a model)
|
|
176
176
|
- Basic types (integer, boolean, string, object, number, date, time, date-time, uuid, etc.) should be lowercased.
|
177
177
|
- An array of models or basic types is specified with `[array<...>]`.
|
178
178
|
- An enum of allowed string values is specified with `[enum<one,two,three>]`.
|
179
|
+
- An enum of allowed values that are defined in the application `[enum<{CURRENCIES}>]`.
|
179
180
|
- An object definition can include the property definitions of its fields, and / or of an additional property for any remaining allowed fields. E.g., `[object<name: string, age: integer, string >]`
|
180
181
|
- Structured data like objects, arrays, pairs, etc., definitions can also be nested; E.g., `[object<pairs:array<object<right:integer,left:integer>>>]`
|
181
182
|
- JSON-Schema `format` attributes can be specified for basic types using `<...>`. For example, `[integer<int64>]` produces JSON `{ "type": "integer", "format": "int64" }`.
|
@@ -24,6 +24,8 @@ module SwaggerYard
|
|
24
24
|
|
25
25
|
rule(:identifier) { name >> (str('::') >> name).repeat }
|
26
26
|
|
27
|
+
rule(:constant) { spaced('{') >> identifier.as(:constant) >> spaced('}') }
|
28
|
+
|
27
29
|
rule(:external_identifier) { name.as(:namespace) >> str('#') >> identifier.as(:identifier) }
|
28
30
|
|
29
31
|
rule(:_false) { str('false').as(:false) }
|
@@ -31,7 +33,7 @@ module SwaggerYard
|
|
31
33
|
rule(:regexp) { stri('regex') >> match['Pp'].maybe >> space >>
|
32
34
|
str('<') >> (str('\\\\') | str('\\>') | match['[^>]']).repeat.as(:regexp) >> str('>') }
|
33
35
|
|
34
|
-
rule(:enum_list) { name.as(:value) >> (spaced(',') >> name.as(:value)).repeat }
|
36
|
+
rule(:enum_list) { (name.as(:value) | constant) >> (spaced(',') >> (name.as(:value) | constant)).repeat }
|
35
37
|
|
36
38
|
rule(:enum) { stri('enum') >> spaced('<') >> enum_list >> spaced('>') }
|
37
39
|
|
@@ -85,6 +87,12 @@ module SwaggerYard
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
90
|
+
rule(constant: simple(:constant)) do
|
91
|
+
constant.to_s.constantize
|
92
|
+
rescue NameError => e
|
93
|
+
raise UnknownConstant, e.message
|
94
|
+
end
|
95
|
+
|
88
96
|
rule(external_identifier: { namespace: simple(:namespace), identifier: simple(:identifier) }) do
|
89
97
|
prefix, name = namespace.to_s, identifier.to_s
|
90
98
|
url, fragment = resolve_uri.call(name, prefix)
|
@@ -104,7 +112,7 @@ module SwaggerYard
|
|
104
112
|
rule(false: simple(:false)) { false }
|
105
113
|
|
106
114
|
rule(enum: subtree(:values)) do
|
107
|
-
{ 'type' => 'string', 'enum' => Array(values) }
|
115
|
+
{ 'type' => 'string', 'enum' => Array(values).flatten }
|
108
116
|
end
|
109
117
|
|
110
118
|
rule(array: subtree(:type)) do
|
data/lib/swagger_yard/version.rb
CHANGED
data/lib/swagger_yard.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagger_yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chtrinh (Chris Trinh)
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,44 +84,44 @@ dependencies:
|
|
84
84
|
name: apivore
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: nokogiri
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: addressable
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,7 +215,7 @@ homepage: http://www.synctv.com
|
|
215
215
|
licenses:
|
216
216
|
- MIT
|
217
217
|
metadata: {}
|
218
|
-
post_install_message:
|
218
|
+
post_install_message:
|
219
219
|
rdoc_options: []
|
220
220
|
require_paths:
|
221
221
|
- lib
|
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
223
|
requirements:
|
224
224
|
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
226
|
+
version: 2.5.0
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
229
|
- - ">="
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
233
|
rubygems_version: 3.0.3
|
234
|
-
signing_key:
|
234
|
+
signing_key:
|
235
235
|
specification_version: 4
|
236
236
|
summary: SwaggerYard API doc through YARD
|
237
237
|
test_files: []
|