Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Custom Specification

Wade Pearce edited this page Jan 15, 2015 · 1 revision

While the library provides 3 different RAML specifications, they may not meed your specific needs for exposing a specification for testing.

The RamlSpecification class is an abstract class that can be extended. The only expectation is that the implementation will expose the getRaml() method.

This way, a developer can load a RAML specification as they need to.

Example

public class MyCustomSpecification extends RamlSpecification {
    private final String serviceName;

    public MyCustomSpecification(String name, String serviceName) {
        super(name);
        this.serviceName = serviceName;
    }

    @Override
    public Raml getRaml(){
        File sharedPathFile = new File(String.format("/path/to/shared/fileserver/location/%s.yml", serviceName));

        if (!sharedPathFile.exists())
            throw new IllegalArgumentException("Specification does not exist for provided service.");

        ResourceLoader loader = new FilePathLoader(sharedPathFile.getParent());

        String raml = FileUtils.readFileToString(sharedPathFile);
        return new RamlDocumentBuilder(loader).build(raml, "/");
    }
}
  • Home
  • [RAML Specifications](RAML Specifications)
    • [Class Path Specification](Class Path Specifications)
    • [File Path Specification](File Path Specifications)
    • [Remote Specification](Remote Path Specifications)
      • Handlers
        • [Zip Archive](Zip Archive Handler)
        • [RAML File](RAML File Handler)
        • [Custom](Custom Resource Handler)
    • [Custom Specification](Custom Specification)
  • [JUnit Test Rule](JUnit Test Rule)

Clone this wiki locally