grape_openapi3 0.1.2 → 0.1.3
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/grape_openapi3/builders/operation_builder.rb +16 -10
- data/lib/grape_openapi3/version.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: 3808df464b57163b3cf5adffec3a2b2bda782648d1ee9ad1731b5fbdf0a64fc5
|
|
4
|
+
data.tar.gz: a7687ffba660a3093fa22f318b0c586957532fe376c82fafc213e0cd1f947a11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b123656dde3a8542bad0647080a74c80d6e1a3a80efa73cfb850298ced9436776e016abcb6a94a7e67901f5b70620840171d9d54b73ae87227acbe45949d5a73
|
|
7
|
+
data.tar.gz: 4b31be25b8a836a6fbd740f66b8e74826bf6f9511e79783d5bc15cc6bbd818a8e83ae853bc88ee6bc574f208972ca6b0d120a91860ba2f9b375bc632bcadf737
|
|
@@ -81,8 +81,13 @@ module GrapeOpenapi3
|
|
|
81
81
|
entity = @route[:success_entity]
|
|
82
82
|
return { "description" => "Success" } unless entity
|
|
83
83
|
|
|
84
|
-
# Unpack hash form: { code: 201, message: "Created", model: ProductEntity }
|
|
85
|
-
description, entity_class = unpack_success(entity)
|
|
84
|
+
# Unpack hash form: { code: 201, message: "Created", model: ProductEntity, schema: {...} }
|
|
85
|
+
description, entity_class, inline_schema = unpack_success(entity)
|
|
86
|
+
|
|
87
|
+
if inline_schema
|
|
88
|
+
media = @route[:produces].first || "application/json"
|
|
89
|
+
return { "description" => description, "content" => { media => { "schema" => inline_schema } } }
|
|
90
|
+
end
|
|
86
91
|
|
|
87
92
|
unless entity_class
|
|
88
93
|
return { "description" => description }
|
|
@@ -98,19 +103,20 @@ module GrapeOpenapi3
|
|
|
98
103
|
{ "description" => description, "content" => { media => { "schema" => schema } } }
|
|
99
104
|
end
|
|
100
105
|
|
|
101
|
-
# Returns [description_string, entity_class_or_nil].
|
|
102
|
-
# Accepts
|
|
106
|
+
# Returns [description_string, entity_class_or_nil, inline_schema_or_nil].
|
|
107
|
+
# Accepts the bare-class form, the hash form with :model, and the hash form with :schema.
|
|
103
108
|
def unpack_success(entity)
|
|
104
109
|
if entity.is_a?(Class)
|
|
105
|
-
return ["Success", entity]
|
|
110
|
+
return ["Success", entity, nil]
|
|
106
111
|
end
|
|
107
112
|
|
|
108
|
-
return ["Success", nil] unless entity.is_a?(Hash)
|
|
113
|
+
return ["Success", nil, nil] unless entity.is_a?(Hash)
|
|
109
114
|
|
|
110
|
-
message
|
|
111
|
-
model
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
message = entity[:message] || entity["message"] || "Success"
|
|
116
|
+
model = entity[:model] || entity["model"]
|
|
117
|
+
inline_schema = entity[:schema] || entity["schema"]
|
|
118
|
+
klass = model.is_a?(Class) ? model : nil
|
|
119
|
+
[message, klass, inline_schema]
|
|
114
120
|
end
|
|
115
121
|
end
|
|
116
122
|
end
|