oas_rails 0.10.1 → 0.11.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 +4 -4
- data/README.md +2 -456
- data/app/views/oas_rails/oas_rails/index.html.erb +118 -6
- data/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb +3 -3
- data/lib/oas_rails/builders/esquema_builder.rb +28 -10
- data/lib/oas_rails/configuration.rb +3 -1
- data/lib/oas_rails/engine.rb +6 -0
- data/lib/oas_rails/version.rb +1 -1
- data/public/oas-rails-assets/rapidoc-min.js +3915 -0
- metadata +3 -2
@@ -7,10 +7,12 @@ module OasRails
|
|
7
7
|
# @param klass [Class] The class for which the schema is built.
|
8
8
|
# @return [Hash] The schema as a JSON-compatible hash.
|
9
9
|
def build_incoming_schema(klass:, model_to_schema_class: EasyTalk)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
build_schema(
|
11
|
+
klass: klass,
|
12
|
+
model_to_schema_class: model_to_schema_class,
|
13
|
+
excluded_columns: OasRails.config.excluded_columns_incoming,
|
14
|
+
exclude_primary_key: true
|
15
|
+
)
|
14
16
|
end
|
15
17
|
|
16
18
|
# Builds a schema for a class when it is used as outgoing API data.
|
@@ -18,21 +20,37 @@ module OasRails
|
|
18
20
|
# @param klass [Class] The class for which the schema is built.
|
19
21
|
# @return [Hash] The schema as a JSON-compatible hash.
|
20
22
|
def build_outgoing_schema(klass:, model_to_schema_class: EasyTalk)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
build_schema(
|
24
|
+
klass: klass,
|
25
|
+
model_to_schema_class: model_to_schema_class,
|
26
|
+
excluded_columns: OasRails.config.excluded_columns_outgoing,
|
27
|
+
exclude_primary_key: false
|
28
|
+
)
|
26
29
|
end
|
27
30
|
|
28
31
|
private
|
29
32
|
|
33
|
+
# Builds a schema with the given configuration.
|
34
|
+
#
|
35
|
+
# @param klass [Class] The class for which the schema is built.
|
36
|
+
# @param model_to_schema_class [Class] The schema builder class.
|
37
|
+
# @param excluded_columns [Array] Columns to exclude from the schema.
|
38
|
+
# @param exclude_primary_key [Boolean] Whether to exclude the primary key.
|
39
|
+
# @return [Hash] The schema as a JSON-compatible hash.
|
40
|
+
def build_schema(klass:, model_to_schema_class:, excluded_columns:, exclude_primary_key:)
|
41
|
+
configure_common_settings(model_to_schema_class: model_to_schema_class)
|
42
|
+
model_to_schema_class.configuration.excluded_columns = excluded_columns
|
43
|
+
model_to_schema_class.configuration.exclude_primary_key = exclude_primary_key
|
44
|
+
|
45
|
+
definition = model_to_schema_class::ActiveRecordSchemaBuilder.new(klass).build_schema_definition
|
46
|
+
EasyTalk::Builders::ObjectBuilder.new(definition).build.as_json
|
47
|
+
end
|
48
|
+
|
30
49
|
# Configures common settings for schema building.
|
31
50
|
#
|
32
51
|
# Excludes associations and foreign keys from the schema.
|
33
52
|
def configure_common_settings(model_to_schema_class: EasyTalk)
|
34
53
|
model_to_schema_class.configuration.exclude_associations = true
|
35
|
-
model_to_schema_class.configuration.exclude_foreign_keys = true
|
36
54
|
end
|
37
55
|
end
|
38
56
|
end
|
@@ -13,7 +13,8 @@ module OasRails
|
|
13
13
|
:possible_default_responses,
|
14
14
|
:response_body_of_default,
|
15
15
|
:http_verbs,
|
16
|
-
:use_model_names
|
16
|
+
:use_model_names,
|
17
|
+
:rapidoc_theme
|
17
18
|
attr_reader :servers, :tags, :security_schema
|
18
19
|
|
19
20
|
def initialize
|
@@ -35,6 +36,7 @@ module OasRails
|
|
35
36
|
@http_verbs = [:get, :post, :put, :patch, :delete]
|
36
37
|
@response_body_of_default = "Hash{ success: !Boolean, message: String }"
|
37
38
|
@use_model_names = false
|
39
|
+
@rapidoc_theme = :rails
|
38
40
|
end
|
39
41
|
|
40
42
|
def security_schema=(value)
|
data/lib/oas_rails/engine.rb
CHANGED
data/lib/oas_rails/version.rb
CHANGED