Class BrAPISchemaReader

java.lang.Object
org.brapi.schematools.core.brapischema.BrAPISchemaReader

public class BrAPISchemaReader extends Object
Utility class for reading BrAPI JSON Schema.
  • Constructor Details

    • BrAPISchemaReader

      public BrAPISchemaReader()
      Creates schema reader with a basic ObjectMapper and V202012 JSonSchema version
  • Method Details

    • readDirectories

      public Response<List<BrAPIClass>> readDirectories(Path schemaDirectory)
      Reads the schema module directories within a parent directory, and validates between schemas. Each directory in the parent directory is a module and the JSON schemas in the directories are object types
      Parameters:
      schemaDirectory - the parent directory that holds all the module directories
      Returns:
      a response containing a list of BrAPIClass with one type per JSON Schema or validation errors
    • readSchema

      public Response<BrAPIClass> readSchema(Path schemaPath, String module) throws BrAPISchemaReaderException
      Reads a single object type from an JSON schema. If the JSON schema contain more than one type definition only the first is returned. There is no validation of referenced schemas
      Parameters:
      schemaPath - a JSON schema file
      module - the module in which the object resides
      Returns:
      a response containing the BrAPIClass for this schema or validation errors
      Throws:
      BrAPISchemaReaderException - if there is a problem reading the JSON schema
    • readSchema

      public Response<List<BrAPIClass>> readSchema(Path path, String schema, String module) throws BrAPISchemaReaderException
      Reads a single object type from an JSON schema string. There is no validation of referenced schemas
      Parameters:
      path - the path of the schema is used to check references, if not supplied then validation is not performed
      schema - a JSON schema string
      module - the module in which the object resides
      Returns:
      a response containing the BrAPIClass for this schema or validation errors
      Throws:
      BrAPISchemaReaderException - if there is a problem reading the JSON schema