swaggard 4.0.0 → 4.0.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/lib/swaggard/swagger/parameters/body.rb +5 -2
- data/lib/swaggard/swagger/parameters/form.rb +0 -3
- data/lib/swaggard/swagger/parameters/list.rb +1 -2
- data/lib/swaggard/swagger/parameters/query.rb +7 -4
- data/lib/swaggard/swagger/response_header.rb +0 -2
- data/lib/swaggard/swagger/type.rb +4 -0
- data/lib/swaggard/version.rb +1 -1
- data/spec/fixtures/api.json +111 -1
- data/spec/fixtures/dummy/app/controllers/pets_controller.rb +1 -0
- data/spec/integration/swaggard_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddc21f0ceaac51adcd841ded044bc82165d666e1dc0fb832f86577a02839f21e
|
|
4
|
+
data.tar.gz: 1140599ec5d0ef899782beb4aec529ca642114eae19509638c4672a23b2982f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0daa594c72416c1620e20d37da32ad90d4b5c6b5a3e16c8ff063366318d9f4d70c101675c249c23f4ad17b80d77975e5e52c251b9f259a8fae7577c9ac278f45
|
|
7
|
+
data.tar.gz: 813fc4f48af7ed3ee726820257f8410247fd96e0059797b6dccc0958b3d0dbb6503c19cb825ce0ddd46125419a365096276f805d88de020d652a247f8255e5b6
|
|
@@ -64,7 +64,11 @@ module Swaggard
|
|
|
64
64
|
def to_doc
|
|
65
65
|
result = @type.to_doc
|
|
66
66
|
result['description'] = @description if @description
|
|
67
|
-
|
|
67
|
+
if @options.present? && @type.is_array?
|
|
68
|
+
result['items']['enum'] = @options
|
|
69
|
+
elsif @options.present?
|
|
70
|
+
result['enum'] = @options
|
|
71
|
+
end
|
|
68
72
|
result
|
|
69
73
|
end
|
|
70
74
|
|
|
@@ -74,7 +78,6 @@ module Swaggard
|
|
|
74
78
|
def parse(string)
|
|
75
79
|
string.gsub!("\n", ' ')
|
|
76
80
|
data_type, required, name, options_and_description = string.match(/\A\[(\S*)\](!)?\s*([\w\[\]]*)\s*(.*)\Z/).captures
|
|
77
|
-
allow_multiple = name.gsub!('[]', '')
|
|
78
81
|
options, description = options_and_description.match(/\A(\[.*\])?(.*)\Z/).captures
|
|
79
82
|
options = options ? options.gsub(/\[?\]?\s?/, '').split(',') : []
|
|
80
83
|
|
|
@@ -26,15 +26,12 @@ module Swaggard
|
|
|
26
26
|
# Example: [Integer] media[media_type_id] ID of the desired media type.
|
|
27
27
|
def parse(string)
|
|
28
28
|
data_type, name, required, description = string.match(/\A\[(\w*)\]\s*([\w\[\]]*)(\(required\))?\s*(.*)\Z/).captures
|
|
29
|
-
allow_multiple = name.gsub!('[]', '')
|
|
30
29
|
|
|
31
30
|
@name = name
|
|
32
31
|
@description = description
|
|
33
32
|
@data_type = data_type.downcase
|
|
34
33
|
@is_required = required.present?
|
|
35
|
-
@allow_multiple = allow_multiple.present?
|
|
36
34
|
end
|
|
37
|
-
|
|
38
35
|
end
|
|
39
36
|
end
|
|
40
37
|
end
|
|
@@ -12,7 +12,12 @@ module Swaggard
|
|
|
12
12
|
|
|
13
13
|
def to_doc
|
|
14
14
|
schema = @type.to_doc
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
if @options.present? && @type.is_array?
|
|
17
|
+
schema['items']['enum'] = @options
|
|
18
|
+
elsif @options.present?
|
|
19
|
+
schema['enum'] = @options
|
|
20
|
+
end
|
|
16
21
|
|
|
17
22
|
{
|
|
18
23
|
'name' => @name,
|
|
@@ -26,11 +31,10 @@ module Swaggard
|
|
|
26
31
|
private
|
|
27
32
|
|
|
28
33
|
# Example: [Array] status Filter by status. (e.g. status[]=1&status[]=2&status[]=3)
|
|
29
|
-
# Example: [Array] status
|
|
34
|
+
# Example: [Array] status! Filter by status. (e.g. status[]=1&status[]=2&status[]=3)
|
|
30
35
|
# Example: [Integer] media[media_type_id] ID of the desired media type.
|
|
31
36
|
def parse(string)
|
|
32
37
|
data_type, required, name, options_and_description = string.match(/\A\[(\S*)\](!)?\s*([\w\[\]]*)\s*(.*)\Z/).captures
|
|
33
|
-
allow_multiple = name.gsub!('[]', '')
|
|
34
38
|
|
|
35
39
|
options, description = options_and_description.match(/\A(\[.*\])?(.*)\Z/).captures
|
|
36
40
|
options = options ? options.gsub(/\[?\]?\s?/, '').split(',') : []
|
|
@@ -39,7 +43,6 @@ module Swaggard
|
|
|
39
43
|
@description = description
|
|
40
44
|
@type = Parsers::Type.run(data_type)
|
|
41
45
|
@is_required = required.present?
|
|
42
|
-
@allow_multiple = allow_multiple.present?
|
|
43
46
|
@options = options
|
|
44
47
|
end
|
|
45
48
|
end
|
|
@@ -21,7 +21,6 @@ module Swaggard
|
|
|
21
21
|
# Example: [Integer] media[media_type_id] ID of the desired media type.
|
|
22
22
|
def parse(string)
|
|
23
23
|
data_type, name, options_and_description = string.match(/\A\[(\S*)\]\s*([\w\-\[\]]*)\s*(.*)\Z/).captures
|
|
24
|
-
allow_multiple = name.gsub!('[]', '')
|
|
25
24
|
|
|
26
25
|
options, description = options_and_description.match(/\A(\[.*\])?(.*)\Z/).captures
|
|
27
26
|
options = options ? options.gsub(/\[?\]?\s?/, '').split(',') : []
|
|
@@ -29,7 +28,6 @@ module Swaggard
|
|
|
29
28
|
@name = name
|
|
30
29
|
@description = description
|
|
31
30
|
@type = data_type
|
|
32
|
-
@allow_multiple = allow_multiple.present?
|
|
33
31
|
@options = options
|
|
34
32
|
end
|
|
35
33
|
end
|
data/lib/swaggard/version.rb
CHANGED
data/spec/fixtures/api.json
CHANGED
|
@@ -1 +1,111 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"version": "0.1",
|
|
5
|
+
"title": "",
|
|
6
|
+
"description": "",
|
|
7
|
+
"contact": {
|
|
8
|
+
"name": ""
|
|
9
|
+
},
|
|
10
|
+
"license": {
|
|
11
|
+
"name": ""
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"servers": [
|
|
15
|
+
{
|
|
16
|
+
"url": "https://localhost:3000/"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "admin/pets",
|
|
22
|
+
"description": "This document describes the API for interacting with Pet resources"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "pets",
|
|
26
|
+
"description": "This document describes the API for interacting with Pet resources"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"paths": {
|
|
30
|
+
"/admin/pets": {
|
|
31
|
+
"get": {
|
|
32
|
+
"tags": [
|
|
33
|
+
"admin/pets"
|
|
34
|
+
],
|
|
35
|
+
"operationId": "index",
|
|
36
|
+
"summary": "return a list of Pets",
|
|
37
|
+
"description": "",
|
|
38
|
+
"parameters": [],
|
|
39
|
+
"responses": {
|
|
40
|
+
"default": {
|
|
41
|
+
"description": "successful operation"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"/pets": {
|
|
47
|
+
"get": {
|
|
48
|
+
"tags": [
|
|
49
|
+
"pets"
|
|
50
|
+
],
|
|
51
|
+
"operationId": "index",
|
|
52
|
+
"summary": "return a list of Pets",
|
|
53
|
+
"description": "",
|
|
54
|
+
"parameters": [],
|
|
55
|
+
"responses": {
|
|
56
|
+
"default": {
|
|
57
|
+
"description": "successful operation"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"/pets/{id}": {
|
|
63
|
+
"get": {
|
|
64
|
+
"tags": [
|
|
65
|
+
"pets"
|
|
66
|
+
],
|
|
67
|
+
"operationId": "show",
|
|
68
|
+
"summary": "return a Pet",
|
|
69
|
+
"description": "",
|
|
70
|
+
"parameters": [
|
|
71
|
+
{
|
|
72
|
+
"name": "id",
|
|
73
|
+
"in": "path",
|
|
74
|
+
"required": true,
|
|
75
|
+
"description": "Scope response to id",
|
|
76
|
+
"schema": {
|
|
77
|
+
"type": "string"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "id",
|
|
82
|
+
"in": "query",
|
|
83
|
+
"required": false,
|
|
84
|
+
"description": "The ID for the Pet",
|
|
85
|
+
"schema": {
|
|
86
|
+
"type": "integer",
|
|
87
|
+
"format": "int32"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "status",
|
|
92
|
+
"in": "query",
|
|
93
|
+
"required": false,
|
|
94
|
+
"description": "! [available, pending, sold] The status of the Pet",
|
|
95
|
+
"schema": {
|
|
96
|
+
"type": "array",
|
|
97
|
+
"items": {
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"responses": {
|
|
104
|
+
"default": {
|
|
105
|
+
"description": "successful operation"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|