model_driven_api 3.1.5 → 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: 6c1a8a56c9fefaf12a3a21235edbb91325a78b9d95a63d0cab7ed3ba12cda2bf
4
- data.tar.gz: 50dcc8e5cc20032bb9e912abed38b43c24c24f6917852bc0ccdc139e55dd080c
3
+ metadata.gz: 2a72bb6cfea6d9f8e0fd4fff0643ee5f73c4c4434532092bd428c7b048c5f9b0
4
+ data.tar.gz: 51c3691214427e0aaa6111cf00a9b476fdb4c91861ba1819a227ea859f924a2d
5
5
  SHA512:
6
- metadata.gz: b140b53e7de7d56349f61713d6b39607132e8bde7c4f15a110f6061f53e76d1d7b4b4460b5ab9c4a5ff107a4dd84dab2c46ad9dba47b2db25b20a756c186c84b
7
- data.tar.gz: 93636d414d491988dbab88b309ac42737c36056637e27e89f8bb36a60b12a9f69fa683ea2d4764b1317ea6963020b68d9422580fbfae5f9277fac24ccfad8b4b
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, {})
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.5".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.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni