Create autogenerated project contract based on modules associated with the project
You can create contracts on the OL Hub by executing the ol create contract command. Contracts are usually created in the OL Hub. Still, the command alternative is handy in certain situations, for example, in continuous integration and deployment use cases where you can re-generate contracts for updated or new assets on an existing project.
You can execute the command in two modes:
- An auto-generated mode in which the contract is generated according to the modules associated with the project.
- OpenAPI mode, in which the user provides an openAPI spec file detailing API methods and fields. The command creates a contract for the project that consists of those methods and fields.
Rules
- The project exists in the OL Hub under the names you specify.
- The project can not contain an existing contract.
Syntax
ol create contract [OPTIONS]
Options
--project
The name of an existing OL Hub project for which to create a contract.
--source-path
The path to an OpenAPI spec file detailing API methods and fields. The file can include references to local external files, provided the reference paths are absolute or relative to the file location.
--type, -t
The contract type (default REST). The options are:
- REST: JSON request/response
- REVERSE-API: BINARY request/response
- WSDL: SOAP request/response
--outputs-json-path, -o
The outputs config json file
Example
Create an autogenerated contract
> ol create contract --project account-activities
$ ol create contract --project account-activities
Create an OpenAPI-based contract
> ol create contract --project account-activities --source-path ./petsore.json
$ ol create contract --project account-activities --source-path ./petsore.json