Class ContractParser

java.lang.Object
com.arc_e_tect.gradle.apionly.transcriberj.model.ContractParser

public final class ContractParser extends Object
Builds a ContractModel from a bundled OpenAPI 3 contract.

Bundled means self-contained: every $ref in a schema points at a schema component in the same document, which is what the API-Only Publisher produces.

  • Method Details

    • parse

      public static ContractModel parse(Path file) throws IOException
      Parses a contract file, read as UTF-8.
      Parameters:
      file - the contract
      Returns:
      the model
      Throws:
      IOException - when the file cannot be read
      ContractModelException - when it is not a bundled OpenAPI 3 contract; the message starts with the file's path
    • parse

      public static ContractModel parse(String text, String source)
      Parses a contract's text.
      Parameters:
      text - the contract, as YAML or JSON
      source - what to call the contract in error messages
      Returns:
      the model
      Throws:
      ContractModelException - when it is not a bundled OpenAPI 3 contract; the message starts with source