Class ContractParser
java.lang.Object
com.arc_e_tect.gradle.apionly.transcriberj.model.ContractParser
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 Summary
Modifier and TypeMethodDescriptionstatic ContractModelParses a contract's text.static ContractModelParses a contract file, read as UTF-8.static ContractModelParses a contract's two documents into one model.
-
Method Details
-
parse
Parses a contract file, read as UTF-8.- Parameters:
file- the contract- Returns:
- the model
- Throws:
IOException- when the file cannot be readContractModelException- when it is not a bundled OpenAPI 3 contract; the message starts with the file's path
-
parse
Parses a contract's two documents into one model.A specification library shares fragments between them: an event payload references the schema of a username the HTTP responses use, so that a username means the same thing either way. Both documents are therefore read into one model, keyed by fragment, and a fragment they share is one component of it -- which is what makes it one generated class rather than two of the same name.
- Parameters:
openapi- the OpenAPI documentasyncapi- the AsyncAPI document, ornullwhen the contract has none- Returns:
- the model
- Throws:
IOException- when a file cannot be readContractModelException- when a document is not what it claims to be
-
parse
Parses a contract's text.- Parameters:
text- the contract, as YAML or JSONsource- 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 withsource
-