Skip to content

Allow custom snippet templates to be provided for multiple snippet formats #197

@wilkinsona

Description

@wilkinsona

At the moment in 1.1, a snippet template can be overridden by providing a classpath resource like org/springframework/restdocs/templates/${name}.snippet. If this snippet isn't found the default template for the current format is loaded from org/springframework/restdocs/templates/${formatId}/${name}.snippet. If a user wants to provide different overrides for different snippet formats they have to rely on the ordering of the classpath to get their template in org/springframework/restdocs/templates/${formatId}/ to appear before the default. This isn't user friendly.

The default templates for a particular format should be renamed to make it clear that they are the default and to allow them to be easily overridden. When resolving a template, the search order would then be:

  1. org/springframework/restdocs/templates/${formatId}/${name}.snippet
  2. org/springframework/restdocs/templates/${name}.snippet
  3. org/springframework/restdocs/templates/${formatId}/default-${name}.snippet

2 is provided largely for backwards compatibility with 1.0.

/cc @andreasevers

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementEnhancement that adds a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions