Create an OpenAPI contract
You can create an OpenAPI-compliant contract and enrich the contract fields with OpenAPI attributes.
Step 1: Set the contract type
-
 Go to the Project page.
-
 Display the
Contracts tab.
-
 On the contract header click
 and select OpenApi.
Step 2: Set OpenAPI method-level attributes
-
In the project side panel, select the contract method
you want to set.
-
 Click the
on the method header and select
Configure OpenApi.
-
Set the following method-level attributes:
- OpenAPI Type: Select the HTTP method of the request.
- Operation ID: Type a unique identifier for the method.
- Method Path: Type the end path of the resource URL, including the path and query parameters that you specify under the OpenAPI Parameters section below (see Step 3.4 below). The default value is the method name. Then click Save.
Step 3: Set OpenAPI field-level attributes
You can enrich any new or existing input or output fields with OpenAPI attributes.
-
 Open the field hierarchy of an input or output node on the flow canvass.
-
 Click the
icon of the field that you want to enrich and select
Edit.
-
 Click the Show more link.
-
Select the location of the field in the context of the HTTP request:
- Header: If the field should be specified in the header, for example, the api-key field.
- Path: If the field is part of the endpoint URL and is not optional, for example, custId in the getCreditcard{custID} path. Append the field to the method path you specified in the Method Path box of the Configure API popup (see step 2.3 above).
- Query: If the field should be specified in the query string part of the endpoint URL. For example, the username field in the /user/login?username path. The field to the method path you specified in the Method Path box of the Configure API popup (see step 2.3 above).
- Body: If the field should be specified in the body payload of the HTTP request. For example, the field creditCard in addCreditCard.Â
-
 Set whether the field is Required or Nullable.
-
In the Field Validation section, set validation rules that the field values match. Each field type has a corresponding set of validation rules.
Field Type
|
Validation Rule
|
Example
|
---|---|---|
String
|
Min Length
|
1
|
Max Length
|
5
| |
Pattern
|
(?<=\.) {2,}(?=[A-Z])
| |
Enums
|
 "available", "pending", "sold"
| |
Int, Long, Double
|
Minimun
|
0.2
|
Maximum
|
0.7
| |
Enums
|
0.2, 0.7, 0.9
| |
Timestamp
|
Format
|
MM-DD-YYYY HH:MM:SS
|
Date
|
Format
|
MM-DD-YYYY
|
Boolean
|
False
| |
Structure
|
Min properties
|
1
|
Max properties
|
99
| |
Collection
|
Min Items
|
1
|
Max Items
|
8
| |
Unique Items
|
False
| |
Binary
|
Updated 4 months ago