zero-rails_openapi 1.1.0 → 1.1.1
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/Gemfile.lock +1 -1
- data/README.md +12 -12
- data/documentation/examples/open_api.rb +14 -12
- data/lib/oas_objs/param_obj.rb +1 -22
- data/lib/oas_objs/schema_obj.rb +5 -6
- data/lib/open_api/generator.rb +1 -0
- data/lib/open_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c0a2065e4a332132fafda9c0b20dc1f10a87ba0
|
4
|
+
data.tar.gz: 8e232f1841f6489ec5fba6e9c3aaf56e0314e416
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24baf84b60c4e2b4a846d5284b34fef596444d1ee90f35fa537d2de87af6b7e35999b44e780db9fbd1a8450675bfe558d9b2d77a51774f120d8133d2fef08f8a
|
7
|
+
data.tar.gz: c238aa68acdc0be8a9d7c3482828ab7feedc69088161622bace745b801111bc28184a9a0612ccb774b5c6accf630e3258c86c88cf160a0e2ee9534544ddc2655
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,16 +14,16 @@ but I dont have enough time now = ▽ =
|
|
14
14
|
|
15
15
|
## Table of Contents
|
16
16
|
|
17
|
-
- [About OAS](
|
18
|
-
- [Installation](
|
19
|
-
- [Configure](
|
20
|
-
- [Usage](
|
21
|
-
- [DSL for documenting your controller](
|
22
|
-
- [Generate JSON Documentation File](
|
23
|
-
- [Use Swagger UI(very beautiful web page) to show your Documentation](
|
17
|
+
- [About OAS](#about-oas) (OpenAPI Specification)
|
18
|
+
- [Installation](#installation)
|
19
|
+
- [Configure](#configure)
|
20
|
+
- [Usage](#usage)
|
21
|
+
- [DSL for documenting your controller](#dsl-for-documenting-your-controller)
|
22
|
+
- [Generate JSON Documentation File](#generate-json-documentation-file)
|
23
|
+
- [Use Swagger UI(very beautiful web page) to show your Documentation](#use-swagger-uivery-beautiful-web-page-to-show-your-documentation)
|
24
24
|
- [Tricks](#tricks)
|
25
|
-
- [Write the DSL Somewhere Else]
|
26
|
-
- [Troubleshooting](
|
25
|
+
- [Write the DSL Somewhere Else](#write-the-dsl-somewhere-else)
|
26
|
+
- [Troubleshooting](#troubleshooting)
|
27
27
|
|
28
28
|
## About OAS
|
29
29
|
|
@@ -161,9 +161,9 @@ end
|
|
161
161
|
ctrl_path 'api/v1/examples'
|
162
162
|
```
|
163
163
|
This option allows you to set the Tag* (which is a node of [OpenApi Object](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#openapi-object)).
|
164
|
-
[Here's a trick](): Using `ctrl_path`, you can write the DSL somewhere else
|
164
|
+
[Here's a trick](#write-the-dsl-somewhere-else-recommend): Using `ctrl_path`, you can write the DSL somewhere else
|
165
165
|
to simplify the current controller.
|
166
|
-
\*
|
166
|
+
\* take the tag from `path.split('/').last`
|
167
167
|
|
168
168
|
- `apis_set` [Optional]
|
169
169
|
|
@@ -395,7 +395,7 @@ In order to use it, you may have to enable CORS, [see](https://github.com/swagge
|
|
395
395
|
|
396
396
|
### Tricks
|
397
397
|
|
398
|
-
#### Write the DSL Somewhere Else
|
398
|
+
#### Write the DSL Somewhere Else
|
399
399
|
|
400
400
|
Does your documentation take too mant lines?
|
401
401
|
Do you want to separate documentation from business controller to simplify both?
|
@@ -48,18 +48,20 @@ OpenApi.configure do |c|
|
|
48
48
|
# https://swagger.io/docs/specification/api-host-and-base-path/
|
49
49
|
# The servers section specifies the API server and base URL.
|
50
50
|
# You can define one or several servers, such as production and sandbox.
|
51
|
-
servers: [
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
servers: [
|
52
|
+
{
|
53
|
+
# [REQUIRED] A URL to the target host.
|
54
|
+
# This URL supports Server Variables and MAY be relative,
|
55
|
+
# to indicate that the host location is relative to the location where
|
56
|
+
# the OpenAPI document is being served.
|
57
|
+
url: 'http://localhost:2333',
|
58
|
+
# An optional string describing the host designated by the URL.
|
59
|
+
description: 'Optional server description, e.g. Main (production) server'
|
60
|
+
},{
|
61
|
+
url: 'http://localhost:3332',
|
62
|
+
description: 'Optional server description, e.g. Internal staging server for testing'
|
63
|
+
}
|
64
|
+
],
|
63
65
|
|
64
66
|
# Authentication
|
65
67
|
# The securitySchemes and security keywords are used to describe the authentication methods used in your API.
|
data/lib/oas_objs/param_obj.rb
CHANGED
@@ -19,7 +19,7 @@ module OpenApi
|
|
19
19
|
|
20
20
|
def process
|
21
21
|
assign(_desc).to_processed 'description'
|
22
|
-
processed.tap { |it| it[:schema] = schema.process_for name }
|
22
|
+
processed.tap { |it| it[:schema] = schema.process_for self[:name] }
|
23
23
|
end
|
24
24
|
|
25
25
|
|
@@ -36,27 +36,6 @@ module OpenApi
|
|
36
36
|
self[key]
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
40
|
-
|
41
|
-
# Interfaces for directly taking the info what you focus on,
|
42
|
-
# The next step you may want to verify the parameters based on these infos.
|
43
|
-
# The implementation of the parameters validator, see:
|
44
|
-
# TODO
|
45
|
-
alias_method :range, :_range
|
46
|
-
alias_method :length, :_length
|
47
|
-
{ # INTERFACE_MAPPING
|
48
|
-
name: %i[name ],
|
49
|
-
required: %i[required ],
|
50
|
-
in: %i[in ],
|
51
|
-
enum: %i[schema enum ],
|
52
|
-
pattern: %i[schema pattern],
|
53
|
-
regexp: %i[schema pattern],
|
54
|
-
type: %i[schema type ],
|
55
|
-
is: %i[schema format ],
|
56
|
-
}.each do |method, path|
|
57
|
-
define_method method do path.inject(processed, &:[]) end # Get value from hash by key path
|
58
|
-
end
|
59
|
-
alias_method :required?, :required
|
60
39
|
end
|
61
40
|
end
|
62
41
|
end
|
data/lib/oas_objs/schema_obj.rb
CHANGED
@@ -141,12 +141,11 @@ module OpenApi
|
|
141
141
|
_default: %i[default dft default_value ],
|
142
142
|
}.each do |key, aliases|
|
143
143
|
define_method key do
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
144
|
+
aliases.each do |alias_name|
|
145
|
+
break if self[key] == false
|
146
|
+
self[key] ||= self[alias_name]
|
147
|
+
end if self[key].nil?
|
148
|
+
self[key]
|
150
149
|
end
|
151
150
|
define_method "#{key}=" do |value| self[key] = value end
|
152
151
|
end
|
data/lib/open_api/generator.rb
CHANGED
data/lib/open_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zero-rails_openapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhandao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|