api_schema 0.2.1 → 0.2.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 759b1621326cb4e389d1d206caa8b46bdaca8ab5
|
4
|
+
data.tar.gz: 77d40d48136c9cc920b7144f8c0c14f5aa477456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da31dd7f8468d0837dbf581d8076ae54f48ba3e834b74507a48d224d1994f9d6c4b1b7b03cb42072bb629b9444334326a8a3d493c929c64b002e73e2f63cc18b
|
7
|
+
data.tar.gz: 02e0d8027769603ed3ec147d14c03750bd8abe001bbd69dd617ed110f62a549c76437377cac98c04273e0955d5f9a601e3e928df132905b2a5e8dee0ea959e0b
|
@@ -6,8 +6,6 @@ module ApiSchema
|
|
6
6
|
subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
|
7
7
|
instance_var_neighbors = "@version_resources"
|
8
8
|
subclass.instance_variable_set(instance_var_neighbors, instance_variable_get(instance_var_neighbors))
|
9
|
-
instance_var_neighbors = "@version_serializers"
|
10
|
-
subclass.instance_variable_set(instance_var_neighbors, instance_variable_get(instance_var_neighbors))
|
11
9
|
end
|
12
10
|
|
13
11
|
def configure
|
@@ -37,11 +35,8 @@ module ApiSchema
|
|
37
35
|
|
38
36
|
def generate_json
|
39
37
|
@api_version.configuration.build
|
40
|
-
@api_version.serializers.each { |s| s.build_references(version_serializers) }
|
41
|
-
|
42
38
|
@api_version.check_consistency
|
43
|
-
|
44
|
-
@api_version.serializers.each { |s| s.build(version_serializers) }
|
39
|
+
@api_version.serializers.each { |s| s.build }
|
45
40
|
@api_version.resources.each { |r| r.build(version_resources) }
|
46
41
|
|
47
42
|
nodes = [@api_version.configuration] + @api_version.serializers + @api_version.resources
|
@@ -4,19 +4,18 @@ module ApiSchema
|
|
4
4
|
|
5
5
|
PriorReference = ::Struct.new(:id, :type, :desc)
|
6
6
|
|
7
|
-
attr_reader :id, :fields, :references, :parent
|
7
|
+
attr_reader :id, :fields, :references, :parent, :api_version
|
8
8
|
attr_accessor :type, :name, :description, :prior_references
|
9
9
|
|
10
|
-
def initialize(id, type,
|
10
|
+
def initialize(id, type, api_version, name=nil, parent_id = nil)
|
11
11
|
@id = id
|
12
12
|
@type = type
|
13
13
|
@name = name || id
|
14
|
-
@
|
14
|
+
@api_version = api_version
|
15
|
+
@parent = api_version.serializers.detect { |s| s.id == parent_id } if parent_id
|
15
16
|
@fields = parent&.fields || []
|
16
17
|
@prior_references = parent&.prior_references || []
|
17
18
|
@references = []
|
18
|
-
|
19
|
-
serializers[id] = self
|
20
19
|
end
|
21
20
|
|
22
21
|
def required_fields
|
@@ -27,16 +26,15 @@ module ApiSchema
|
|
27
26
|
@prior_references << PriorReference.new(refernce_id, type, desc)
|
28
27
|
end
|
29
28
|
|
30
|
-
def build
|
31
|
-
build_references
|
29
|
+
def build
|
30
|
+
build_references
|
32
31
|
sd = self
|
33
32
|
swagger_schema(id) { schema_for(sd) }
|
34
33
|
end
|
35
34
|
|
36
|
-
def build_references
|
35
|
+
def build_references
|
37
36
|
@prior_references.each do |pr|
|
38
|
-
|
39
|
-
reference = serializers[pr.id].clone
|
37
|
+
reference = api_version.serializers.detect { |s| s.id == pr.id }
|
40
38
|
reference.type = pr.type
|
41
39
|
reference.description = pr.desc
|
42
40
|
reference.name = reference.name.to_s.pluralize if reference.type == :array
|
@@ -4,13 +4,13 @@ module ApiSchema
|
|
4
4
|
private
|
5
5
|
|
6
6
|
def serializer(id, structure: :object, name: nil, parent: nil)
|
7
|
-
serializer = SerializerDefinition.new(id, structure,
|
7
|
+
serializer = SerializerDefinition.new(id, structure, api_version, name, parent)
|
8
8
|
yield serializer if block_given?
|
9
9
|
api_version.serializers << serializer
|
10
10
|
end
|
11
11
|
|
12
12
|
def array_serializer(id, name: nil, parent: nil)
|
13
|
-
serializer = SerializerDefinition.new(id, :array,
|
13
|
+
serializer = SerializerDefinition.new(id, :array, api_version, name, parent)
|
14
14
|
yield serializer if block_given?
|
15
15
|
api_version.serializers << serializer
|
16
16
|
end
|
data/lib/api_schema/version.rb
CHANGED