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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17346f3dae0e585379c27fc085e3dba2d22546eb5b01f31e2575ea1c2237e95c
4
- data.tar.gz: a346029b12de6f15c72d0caa3b4bd5e59ccff4741c474e7bb3ecfa70a8dc878e
3
+ metadata.gz: 92fee53b6f39a4a44e733619571d5c051054df3e7721058b50d6f18654898d73
4
+ data.tar.gz: 93e2c4acd9fb8c523a39c916257e41a5c6426e5033439f814223d91397317606
5
5
  SHA512:
6
- metadata.gz: 91f408ddf67843e217bdac7a69e18e67b513389e7ccb42b8f1a1a27d7781deefc65628fc7239909a3b4a8d9dc7c66236bc3e0bb076e623b93371bb9929517a4c
7
- data.tar.gz: a7a235cad5fbf1f2289c216562bdf7814721589393facf775fac2a39e84e589384d346db16af05c58760ec8e08889b3173e36aae41052e839e80636e76d23f27
6
+ metadata.gz: 23e2f8c39bdaf2a8009dc7f78b4a8f589da25737fa4cb3e77ab89395abe84459a52106d85aa026b533bbefdfe646cfa9c7fc7d9ede512be5edd4e242ada164ba
7
+ data.tar.gz: b893eddf59099d0fc2cba25486d5e7b2073b2386d3e0805addf7f7d2b280ccdd165038cd5323ab5315ecd8ac7a5ad07b0b6541471c6c14f7ff5890309de313cf
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SwaggerYard [![Build Status](https://travis-ci.org/livingsocial/swagger_yard.svg?branch=master)](https://travis-ci.org/livingsocial/swagger_yard) #
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
@@ -1,3 +1,3 @@
1
1
  module SwaggerYard
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/swagger_yard.rb CHANGED
@@ -19,6 +19,7 @@ require "swagger_yard/directives"
19
19
 
20
20
  module SwaggerYard
21
21
  class Error < StandardError; end
22
+ class UnknownConstant < Error; end
22
23
  class InvalidTypeError < Error; end
23
24
  class UndefinedSchemaError < Error; end
24
25
 
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
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: 2020-05-21 00:00:00.000000000 Z
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: '12'
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: '12'
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: '1.6'
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: '1.6'
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: '1.8'
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: '1.8'
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: 2.4.0
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: 2.4.0
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: '0'
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: []