praxis 2.0.pre.20 → 2.0.pre.21
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/CHANGELOG.md +2 -0
- data/lib/praxis/docs/open_api/schema_object.rb +12 -12
- data/lib/praxis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22211954ff9fa77a0667e1daf3ae00b30d1d599cd5a25b65547321295e5a2fcb
|
4
|
+
data.tar.gz: 3ec2f9c7f2cd9d261f09675a25ca5211131c65d58cc088a539f60f273d5ac207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d46f5cd5b91786467262f2baf3e2e60d27431f3b01ac7d674508f66b33046cb26b6489541eb55324354762964f017dc0e448f69d895dfc7804149e87f57b3b0b
|
7
|
+
data.tar.gz: 957d3f7d32a54f8990e1697a6e6c8182042f15879ef0f8689298ca751b5e0fc5eb64a9f530064066d8722f41b57ddf014889736c5959097c013759ba911beddd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
## next
|
4
4
|
|
5
|
+
## 2.0.pre.21
|
6
|
+
* Fix nullable attribute in OpenApi generation
|
5
7
|
## 2.0.pre.20
|
6
8
|
* Changed the behavior of dev-mode when validate_responses. Now they return a 500 status code (instead of a 400) but with the same validation error format body.
|
7
9
|
* validate_responses is meant to catch the application returning non-compliant responses for development only. As such, a 500 is much more appropriate and clear, as the validation is done on the behavior of the server, and not on the information sent by the client (i.e., it is a server problem, not reacting the way the API is defined)
|
@@ -37,33 +37,33 @@ module Praxis
|
|
37
37
|
h = @attribute_options[:description] ? { 'description' => @attribute_options[:description] } : {}
|
38
38
|
|
39
39
|
Praxis::Docs::OpenApiGenerator.instance.register_seen_component(type)
|
40
|
-
h.merge('$ref' => "#/components/schemas/#{type.id}")
|
40
|
+
h.merge!('$ref' => "#/components/schemas/#{type.id}")
|
41
41
|
elsif @collection
|
42
42
|
items = OpenApi::SchemaObject.new(info: type.member_type).dump_schema(allow_ref: allow_ref, shallow: false)
|
43
43
|
h = @attribute_options[:description] ? { 'description' => @attribute_options[:description] } : {}
|
44
|
-
h.merge(type: 'array', items: items)
|
45
|
-
else
|
46
|
-
# Object
|
44
|
+
h.merge!(type: 'array', items: items)
|
45
|
+
else # Attributor::Struct, etc
|
47
46
|
props = type.attributes.transform_values do |definition|
|
48
47
|
OpenApi::SchemaObject.new(info: definition).dump_schema(allow_ref: true, shallow: shallow)
|
49
48
|
end
|
50
|
-
{ type: :object, properties: props } # TODO: Example?
|
49
|
+
h = { type: :object, properties: props } # TODO: Example?
|
51
50
|
end
|
52
51
|
else
|
53
52
|
# OpenApi::SchemaObject.new(info:target).dump_schema(allow_ref: allow_ref, shallow: shallow)
|
54
53
|
# TODO...we need to make sure we can use refs in the underlying components after the first level...
|
55
54
|
# ... maybe we need to loop over the attributes if it's an object/struct?...
|
56
55
|
h = type.as_json_schema(shallow: shallow, example: nil, attribute_options: @attribute_options)
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
h
|
58
|
+
# Tag on OpenAPI specific requirements that aren't already added in the underlying JSON schema model
|
59
|
+
# Nullable: (it seems we need to ensure there is a null option to the enum, if there is one)
|
60
|
+
if @attribute_options[:null]
|
61
|
+
h[:nullable] = @attribute_options[:null]
|
62
|
+
h[:enum] = h[:enum] + [nil] if h[:enum] && !h[:enum].include?(nil)
|
65
63
|
end
|
66
64
|
|
65
|
+
h
|
66
|
+
|
67
67
|
# # TODO: FIXME: return a generic object type if the passed info was weird.
|
68
68
|
# return { type: :object } unless info
|
69
69
|
|
data/lib/praxis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praxis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.pre.
|
4
|
+
version: 2.0.pre.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep M. Blanquer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-02-
|
12
|
+
date: 2022-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|