Add infer_expand_nested_from_expand configuration docs

This commit is contained in:
Muhammad Nawzad 2024-01-30 16:29:58 +03:00
parent f90a997e30
commit d212a2904e
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2
2 changed files with 7 additions and 1 deletions

View File

@ -61,6 +61,7 @@ Please note that the configurations options below are defined in the `Schemable`
| `enum_prefix_for_simple_enum` | The prefix to be used for the enum values when `mongoid` is used. | `nil` | | `enum_prefix_for_simple_enum` | The prefix to be used for the enum values when `mongoid` is used. | `nil` |
| `enum_suffix_for_simple_enum` | The suffix to be used for the enum values when `mongoid` is used. | `nil` | | `enum_suffix_for_simple_enum` | The suffix to be used for the enum values when `mongoid` is used. | `nil` |
| `infer_attributes_from_custom_method` | The name of the custom method that is used to get the attributes to be generated in the schema. See [Annex 1.3 - Infer attributes from custom method](#annex-13---infer-attributes-from-custom-method) for more information. | `nil` | | `infer_attributes_from_custom_method` | The name of the custom method that is used to get the attributes to be generated in the schema. See [Annex 1.3 - Infer attributes from custom method](#annex-13---infer-attributes-from-custom-method) for more information. | `nil` |
| `infer_expand_nested_from_expand` | Configures `ResponseSchemaGenerator`'s `generate` method to prevent expansion for nested relationships. It globally set the value of `expand_nested` to the same value as `expand` by setting the configuration to `true` | `flase` |
| `infer_attributes_from_jsonapi_serializable` | Whether or not to infer the attributes from the `JSONAPI::Serializable::Resource` class. See the previous example [Annex 1.1 - Use serialized instance](#annex-11---use-serialized-instance) for more information. | `false` | | `infer_attributes_from_jsonapi_serializable` | Whether or not to infer the attributes from the `JSONAPI::Serializable::Resource` class. See the previous example [Annex 1.1 - Use serialized instance](#annex-11---use-serialized-instance) for more information. | `false` |
| `custom_meta_response_schema` | A hash of custom meta response schema that can be used to override the default meta response schema. See [Annex 1.4 - Custom meta response schema](#annex-14---custom-meta-response-schema) for more information. | `nil` | | `custom_meta_response_schema` | A hash of custom meta response schema that can be used to override the default meta response schema. See [Annex 1.4 - Custom meta response schema](#annex-14---custom-meta-response-schema) for more information. | `nil` |
| `pagination_enabled` | Enable pagination schema generation in the `meta` section of the response schema. | `true` | | `pagination_enabled` | Enable pagination schema generation in the `meta` section of the response schema. | `true` |
@ -400,7 +401,7 @@ module Swagger
"#{schema_instance.model}CreateRequest": schema_instance.camelize_keys(Schemable::RequestSchemaGenerator.new(schema_instance).generate_for_create), "#{schema_instance.model}CreateRequest": schema_instance.camelize_keys(Schemable::RequestSchemaGenerator.new(schema_instance).generate_for_create),
"#{schema_instance.model}UpdateRequest": schema_instance.camelize_keys(Schemable::RequestSchemaGenerator.new(schema_instance).generate_for_update), "#{schema_instance.model}UpdateRequest": schema_instance.camelize_keys(Schemable::RequestSchemaGenerator.new(schema_instance).generate_for_update),
"#{schema_instance.model}Response": schema_instance.camelize_keys(Schemable::ResponseSchemaGenerator.new(schema_instance).generate(expand: true, collection: true, relationships_to_exclude_from_expansion: %w[addresses stores attachments])), "#{schema_instance.model}Response": schema_instance.camelize_keys(Schemable::ResponseSchemaGenerator.new(schema_instance).generate(expand: true, collection: true, relationships_to_exclude_from_expansion: %w[addresses stores attachments])),
"#{schema_instance.model}ResponseExpanded": schema_instance.camelize_keys(Schemable::ResponseSchemaGenerator.new(schema_instance).generate(expand: true)) "#{schema_instance.model}ResponseExpanded": schema_instance.camelize_keys(Schemable::ResponseSchemaGenerator.new(schema_instance).generate(expand: true, expand_nested: true))
] ]
end end
end end

View File

@ -41,6 +41,11 @@ Schemable.configure do |config|
# #
# config.infer_attributes_from_custom_method = nil # config.infer_attributes_from_custom_method = nil
# If you want to recursively expand the relationships in the response schema
# then set this option to true, otherwise set it to false (default).
#
# config.infer_expand_nested_from_expand = true
# If you want to get the list of attributes from the jsonapi-rails gem's # If you want to get the list of attributes from the jsonapi-rails gem's
# JSONAPI::Serializable::Resource class, set this option to true. # JSONAPI::Serializable::Resource class, set this option to true.
# It uses the attribute_blocks method to get the list of attributes. # It uses the attribute_blocks method to get the list of attributes.