swaggard 4.0.0 → 4.0.2
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 +6 -3
- 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 +157 -1
- data/spec/fixtures/dummy/app/controllers/pets_controller.rb +8 -0
- data/spec/fixtures/dummy/app/serializers/pet_body.rb +3 -0
- data/spec/fixtures/dummy/config/routes.rb +1 -1
- data/spec/integration/swaggard_spec.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1027d54356ae054b3765498f191cb2f20bfbbf0f9904ceb303fd4d5c2db22174
|
|
4
|
+
data.tar.gz: 6fb462d05a13551c8c257e62756cd2f5b1e7fcb38165dc7531b06286a9709fd8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c22983eb886206224a65d7ba44ed909236031af1fdb6d38fab0e99639f68e404765e630b62d176eccb5458d4a72183b9a63e7ba959087348d6058b96dd23e03
|
|
7
|
+
data.tar.gz: 2da94dd7872f071794dc924b4245f1d9b70619b1867f4ba36edaf3a803746ced0d96c75d0fc3b7cb6d29d21fea4804932b0f935a132355bf5fbc78491f1ab30f
|
|
@@ -22,7 +22,7 @@ module Swaggard
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def empty?
|
|
25
|
-
@definition.empty?
|
|
25
|
+
@definition.empty? && @definition_id == @definition.id
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def to_request_body
|
|
@@ -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,157 @@
|
|
|
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
|
+
"post": {
|
|
62
|
+
"tags": [
|
|
63
|
+
"pets"
|
|
64
|
+
],
|
|
65
|
+
"operationId": "create",
|
|
66
|
+
"summary": "create a new Pet",
|
|
67
|
+
"description": "",
|
|
68
|
+
"parameters": [],
|
|
69
|
+
"responses": {
|
|
70
|
+
"default": {
|
|
71
|
+
"description": "successful operation"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"requestBody": {
|
|
75
|
+
"required": true,
|
|
76
|
+
"content": {
|
|
77
|
+
"application/json": {
|
|
78
|
+
"schema": {
|
|
79
|
+
"$ref": "#/components/schemas/PetBody"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"/pets/{id}": {
|
|
87
|
+
"get": {
|
|
88
|
+
"tags": [
|
|
89
|
+
"pets"
|
|
90
|
+
],
|
|
91
|
+
"operationId": "show",
|
|
92
|
+
"summary": "return a Pet",
|
|
93
|
+
"description": "",
|
|
94
|
+
"parameters": [
|
|
95
|
+
{
|
|
96
|
+
"name": "id",
|
|
97
|
+
"in": "path",
|
|
98
|
+
"required": true,
|
|
99
|
+
"description": "Scope response to id",
|
|
100
|
+
"schema": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "id",
|
|
106
|
+
"in": "query",
|
|
107
|
+
"required": false,
|
|
108
|
+
"description": "The ID for the Pet",
|
|
109
|
+
"schema": {
|
|
110
|
+
"type": "integer",
|
|
111
|
+
"format": "int32"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "status",
|
|
116
|
+
"in": "query",
|
|
117
|
+
"required": false,
|
|
118
|
+
"description": "! [available, pending, sold] The status of the Pet",
|
|
119
|
+
"schema": {
|
|
120
|
+
"type": "array",
|
|
121
|
+
"items": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"responses": {
|
|
128
|
+
"default": {
|
|
129
|
+
"description": "successful operation"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"components": {
|
|
136
|
+
"schemas": {
|
|
137
|
+
"PetBody": {
|
|
138
|
+
"type": "object",
|
|
139
|
+
"properties": {
|
|
140
|
+
"name": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "The name of the Pet"
|
|
143
|
+
},
|
|
144
|
+
"age": {
|
|
145
|
+
"type": "integer",
|
|
146
|
+
"format": "int32",
|
|
147
|
+
"description": "The age of the Pet"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"PetsController.create_body": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"properties": {}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -9,7 +9,15 @@ class PetsController < ApplicationController
|
|
|
9
9
|
# return a Pet
|
|
10
10
|
#
|
|
11
11
|
# @query_parameter [Integer] id The ID for the Pet
|
|
12
|
+
# @query_parameter [Array<String>] status! [available, pending, sold] The status of the Pet
|
|
12
13
|
def show
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
# create a new Pet
|
|
17
|
+
#
|
|
18
|
+
# @body_required
|
|
19
|
+
# @body_definition PetBody
|
|
20
|
+
def create
|
|
21
|
+
end
|
|
22
|
+
|
|
15
23
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swaggard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adrian Gomez
|
|
@@ -152,6 +152,7 @@ files:
|
|
|
152
152
|
- spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
|
|
153
153
|
- spec/fixtures/dummy/app/controllers/application_controller.rb
|
|
154
154
|
- spec/fixtures/dummy/app/controllers/pets_controller.rb
|
|
155
|
+
- spec/fixtures/dummy/app/serializers/pet_body.rb
|
|
155
156
|
- spec/fixtures/dummy/config/application.rb
|
|
156
157
|
- spec/fixtures/dummy/config/environments/development.rb
|
|
157
158
|
- spec/fixtures/dummy/config/routes.rb
|
|
@@ -188,6 +189,7 @@ test_files:
|
|
|
188
189
|
- spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
|
|
189
190
|
- spec/fixtures/dummy/app/controllers/application_controller.rb
|
|
190
191
|
- spec/fixtures/dummy/app/controllers/pets_controller.rb
|
|
192
|
+
- spec/fixtures/dummy/app/serializers/pet_body.rb
|
|
191
193
|
- spec/fixtures/dummy/config/application.rb
|
|
192
194
|
- spec/fixtures/dummy/config/environments/development.rb
|
|
193
195
|
- spec/fixtures/dummy/config/routes.rb
|