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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b766639dad295072af7561e8f833b1324b40cf8fbe3dd541f50b28f584b776a
4
- data.tar.gz: ae90d2dfa58d2b6de7739fb4da1133b6e6e1bdbee54c9be6446de073989de9c2
3
+ metadata.gz: 3808df464b57163b3cf5adffec3a2b2bda782648d1ee9ad1731b5fbdf0a64fc5
4
+ data.tar.gz: a7687ffba660a3093fa22f318b0c586957532fe376c82fafc213e0cd1f947a11
5
5
  SHA512:
6
- metadata.gz: ceffb4098ee59dc64bf447603126f56ec62a422abec5c525aa48fc45fe71c2c30f7ab4eb276a9ba30fba1a46cfbc6a6317ebdad332b649d55c310ebd65b3105f
7
- data.tar.gz: d74161cb5c277c94bb578a2dadc54ab5878586fd44e51de024242375a5f1840212b25d83bc8746e0bb06199e86d5112f6150b5c295032a9cba29d0f61a23e573
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 both the bare-class form and the hash form.
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 = entity[:message] || entity["message"] || "Success"
111
- model = entity[:model] || entity["model"]
112
- klass = model.is_a?(Class) ? model : nil
113
- [message, klass]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GrapeOpenapi3
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_openapi3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rodrigonbarreto