model_driven_api 3.1.4 → 3.1.6

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: fe66f672447c0aa658740f932e8245bf57a02fc0531e79520e5c426410e2c9a3
4
- data.tar.gz: 131b5eb93497c89b0d03506398e6beb2ac3b2fb5b74d8af19b7488151eb4b1cd
3
+ metadata.gz: 2a72bb6cfea6d9f8e0fd4fff0643ee5f73c4c4434532092bd428c7b048c5f9b0
4
+ data.tar.gz: 51c3691214427e0aaa6111cf00a9b476fdb4c91861ba1819a227ea859f924a2d
5
5
  SHA512:
6
- metadata.gz: 22ddc373d73b8c08c0dd44f735c7c8faccea38850557d51418ca1d07e4cb9eb393df2fb9fa51f491074cefec20a55b4ede0c98eff1dbfbd8d8081e56c935ebcd
7
- data.tar.gz: 103e01d9c18ab24e997bf10b2212cc8fddf56fbc3764c591ce72444aacb79c1b75c139e02d5bf74b825dc25839df0c4182d60c9417d515ea266ee2f505e5cfc6
6
+ metadata.gz: af0ddbc93b40f315b170630facacb7357022880e560502c83f4e2f2e5ac4342ffb5eaece4be1e1e591d5f0fa6b0a447b1e49ecbd6f9bf2975ee15c2a4b5c8743
7
+ data.tar.gz: f6318805dc382e2ce28494a74174d01bd53fb12749151a6ea5b21d4ea610dd23a9a4ac8c3dce09ff241c21202f8c3291694056917024781df012f39ac8e25460
@@ -84,12 +84,14 @@ class Api::V2::InfoController < Api::V2::ApplicationController
84
84
  method_key.type.to_s
85
85
  end
86
86
 
87
- def create_properties_from_model(model, dsl)
87
+ def create_properties_from_model(model, dsl, remove_reserved = false)
88
88
  JSON.parse(model.new.to_json(dsl)).keys.map do |k|
89
- # Rails.logger.debug "###################### Model #{model.model_name.human rescue ""} Key #{k}"
90
89
  type = compute_type(model, k)
91
- # Rails.logger.debug "###################### Model #{model.model_name.human rescue ""} Type for #{k} is #{type}"
92
- if type == "method"
90
+
91
+ # Remove fields that cannot be created or updated
92
+ if remove_reserved && %w( id created_at updated_at lock_version).include?(k.to_s)
93
+ nil
94
+ elsif type == "method"
93
95
  [k, { "type": "object", "additionalProperties": true }]
94
96
  elsif type == "date"
95
97
  [k, { "type": "string", "format": "date" }]
@@ -468,7 +470,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
468
470
  "properties": {
469
471
  "#{model.singularize}": {
470
472
  "type": "object",
471
- "properties": create_properties_from_model(d, (d.json_attrs rescue {}))
473
+ "properties": create_properties_from_model(d, {}, true)
472
474
  }
473
475
  }
474
476
  }
@@ -611,7 +613,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
611
613
  "properties": {
612
614
  "#{model.singularize}": {
613
615
  "type": "object",
614
- "properties": create_properties_from_model(d, {})
616
+ "properties": create_properties_from_model(d, {}, true)
615
617
  }
616
618
  }
617
619
  }
@@ -660,7 +662,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
660
662
  "properties": {
661
663
  "#{model.singularize}": {
662
664
  "type": "object",
663
- "properties": create_properties_from_model(d, {})
665
+ "properties": create_properties_from_model(d, {}, true)
664
666
  }
665
667
  }
666
668
  }
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.1.4".freeze
2
+ VERSION = "3.1.6".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni