praxis 2.0.pre.20 → 2.0.pre.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ade185970597f7537bf75a761bb1e1a01739f2e696ad006f8421037320051c3
4
- data.tar.gz: fd9e948ba2f7d48c0abc94f70bec9cad3f594b41d82f9ce9445df28be010fe14
3
+ metadata.gz: 22211954ff9fa77a0667e1daf3ae00b30d1d599cd5a25b65547321295e5a2fcb
4
+ data.tar.gz: 3ec2f9c7f2cd9d261f09675a25ca5211131c65d58cc088a539f60f273d5ac207
5
5
  SHA512:
6
- metadata.gz: 66e64aafead42894ca61670c3a1ec3411d274d8d6cd80111d28088efd33f4c9641ed88d031cb308d0f0a7896264d877d4aa38a33a7f4944abc56aeb86dac2b81
7
- data.tar.gz: e98a655a44a2e0d43b384e14d03ede406ace7ac79a41805e5b31178a07c902ac118e70e8ea8ef26d3cbfb70eca7404e53dd5a636f98b543c91dd90b1385926f0
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
- # 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)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Praxis
4
- VERSION = '2.0.pre.20'
4
+ VERSION = '2.0.pre.21'
5
5
  end
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.20
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-07 00:00:00.000000000 Z
12
+ date: 2022-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport