diff --git a/README.md b/README.md index 113ca00..e8c3a4f 100644 --- a/README.md +++ b/README.md @@ -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_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_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` | | `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` | @@ -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}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}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 diff --git a/lib/templates/schemable.rb b/lib/templates/schemable.rb index ff7c59a..6400b46 100644 --- a/lib/templates/schemable.rb +++ b/lib/templates/schemable.rb @@ -41,6 +41,11 @@ Schemable.configure do |config| # # 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 # JSONAPI::Serializable::Resource class, set this option to true. # It uses the attribute_blocks method to get the list of attributes.