Class PageContractSchema

java.lang.Object
org.apache.juneau.console.PageContractSchema

public final class PageContractSchema extends Object
Loads juneau-page.schema.json from the classpath and validates contracts against it, plus the cross-reference rules R-1..R-4 the schema cannot express. Used by PageCapture in dev mode and by PageContractAssert in tests.
Example:

List<String> errors = PageContractSchema.get().validate(contractJson); if (! errors.isEmpty()) throw new IllegalStateException(String.join("\n", errors)); // With the <template> ids found in the rendered page, R-4 is checked too: errors = PageContractSchema.get().validate(contractJson, Set.of("jc-seg-1", "header.banner"));

Since:
10.0.0
  • Field Details

  • Method Details

    • get

      public static PageContractSchema get()
      Returns the shared instance.
      Returns:
      The shared instance, never null.
    • schemaJson

      public String schemaJson()
      Returns the schema text exactly as shipped.
      Returns:
      The schema JSON.
    • validate

      public List<String> validate(String contractJson)
      Validates a contract against the schema and rules R-1..R-3.
      Parameters:
      contractJson - The contract JSON.
      Returns:
      The findings, empty when valid.
    • validate

      public List<String> validate(String contractJson, Set<String> templateIds)
      Validates a contract against the schema and rules R-1..R-4.
      Parameters:
      contractJson - The contract JSON.
      templateIds - The <template data-card|data-slot> ids present in the page, or null to skip R-4.
      Returns:
      The findings, empty when valid.