rswag-schema_components 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b041fd5f764b0ee034841531569e236293fbd6f196f73d473d7a509924a1651
4
- data.tar.gz: 746c26cd16bd854bac11cb0bca07d4c24f4462238789c37155b6e5b18d0bbff6
3
+ metadata.gz: e4a83a9214d990e259d26b551a5cec0c13d91c6ca42d0b452303854bd68ab04a
4
+ data.tar.gz: e212ca7db382ef8ae1b4c66a49e7c65ee3f6650ffe58e64989379d759b0c078c
5
5
  SHA512:
6
- metadata.gz: d8b04bb43f33b1becfeda6d99ab5402f8dedd7f8d81cd19b6e0219bdadd7b933cbee728b914e75097bee8b25d0c13fcebc12b39f69ab536b8cb298dfa7f8a07b
7
- data.tar.gz: e50f111d411b9b2ebd4d589cd1d468c6220accf366d73a2c2c1f0c4ac61904d584e396c82da5c8531c00515be41e27eb220ea45305c4996b86dffa52280ed787
6
+ metadata.gz: 491792f034575c3bda0d4e188a58fbe80ceae052c418f1342ebb18ecfaa96d615e7726c1c31d2e560ae3cbe7d4ab577695c0999db75a81a1256f0b595c4c615b
7
+ data.tar.gz: c613bd114d13304bc6627f3b6acf69707f56a877c12095c4b7216e20548e5a02acfd6118d6c8cc85f2fe9b3f5ab134dbc6ff6ab8e006600ebe7cab1db2fc0a53
@@ -7,7 +7,7 @@ module Rswag
7
7
 
8
8
  included do
9
9
  class << self
10
- attr_accessor :schema_value
10
+ attr_accessor :schema_value, :schema_hidden_value
11
11
 
12
12
  def schema(schema_definition)
13
13
  self.schema_value = if superclass.respond_to?(:schema_value)
@@ -17,11 +17,19 @@ module Rswag
17
17
  schema_definition
18
18
  end
19
19
  end
20
+
21
+ def schema_hidden(flag = false)
22
+ self.schema_hidden_value = flag
23
+ end
20
24
  end
21
25
 
22
26
  def to_schema
23
27
  self.class.schema_value
24
28
  end
29
+
30
+ def hidden?
31
+ self.class.schema_hidden_value
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -27,18 +27,29 @@ module Rswag
27
27
  load_classes.each do |klass|
28
28
  component_name = extract_component_name(klass)
29
29
 
30
- definition = klass.new.to_schema
30
+ component = klass.new
31
+ definition = component.to_schema
32
+
33
+ if component.hidden?
34
+ next
35
+ end
31
36
 
32
37
  if components[component_name].present?
33
38
  raise "Duplicate component name \"#{component_name}\" found in \"#{definitions_path}\""
34
39
  end
35
40
 
36
- components[component_name] = definition.merge(title: component_name)
41
+ definition = definition.merge(title: component_name) if type_allows_title?
42
+
43
+ components[component_name] = definition
37
44
  end
38
45
 
39
46
  components
40
47
  end
41
48
 
49
+ private def type_allows_title?
50
+ type == "schemas"
51
+ end
52
+
42
53
  private def load_classes
43
54
  Dir.glob(base_path.join("#{definitions_path}/**/*")).filter_map do |file_path|
44
55
  next if File.directory?(file_path)
@@ -1,5 +1,5 @@
1
1
  module Rswag
2
2
  module SchemaComponents
3
- VERSION = "0.1.4"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rswag-schema_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Klitzke
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-03 00:00:00.000000000 Z
10
+ date: 2025-04-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.6.5
69
+ rubygems_version: 3.6.2
70
70
  specification_version: 4
71
71
  summary: Schema Components for Rswag.
72
72
  test_files: []