Class OpenAPIContractBuilder
java.lang.Object
io.vertx.openapi.contract.OpenAPIContractBuilder
Builder for OpenAPIContracts.
In the simplest case (you only have one contract) you must either provide a path to your openapi-contract in json
or yaml format or an already parsed openapi-spec as a JsonObject.
See setContractPath(String) and setContract(JsonObject).
If your contract is split across different files you must load the main contract as described above and additionally
provide the referenced contract parts. See putAdditionalContractPartPath(String, String),
setAdditionalContractPartPaths(Map),
putAdditionalContractPart(String, JsonObject),
setAdditionalContractParts(Map).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the contract.mediaTypeRegistry(MediaTypeRegistry registry) putAdditionalContractPart(String ref, JsonObject contractPart) Puts an additional contract part that is referenced by the main contract.putAdditionalContractPartPath(String ref, String path) Puts an additional contract part path that is referenced by the main contract.setAdditionalContractPartPaths(Map<String, String> contractPartPaths) Uses the additional contract part paths from the provided map to resolve referenced contract parts.setAdditionalContractParts(Map<String, JsonObject> contractParts) Uses the additional contract parts from the provided map to resolve referenced additional contract parts.setContract(JsonObject contract) Sets the contract.setContractPath(String contractPath) Sets the path to the contract.
-
Constructor Details
-
OpenAPIContractBuilder
-
-
Method Details
-
setContractPath
Sets the path to the contract. Either provide the path to the contract or the parsed contract, not both. Overrides the contract set bysetContract(JsonObject).- Parameters:
contractPath- The path to the contract- Returns:
- The builder, for a fluent interface
-
setContract
Sets the contract. Either provide the contract or the path to the contract, not both. Overrides the contract set bysetContractPath(String).- Parameters:
contract- The parsed contract- Returns:
- The builder, for a fluent interface
-
putAdditionalContractPartPath
Puts an additional contract part path that is referenced by the main contract. This method can be called multiple times to add multiple referenced additional contract parts. Overrides a previously added additional contract part when the same reference is used.- Parameters:
ref- The unique reference of the additional contract part.path- The path to the contract part.- Returns:
- The builder, for a fluent interface
-
setAdditionalContractPartPaths
Uses the additional contract part paths from the provided map to resolve referenced contract parts. Replaces all previously put additional contract part paths byputAdditionalContractPartPath(String, String). If the same reference is used it overrides the additional contract part added byputAdditionalContractPart(String, JsonObject)orsetAdditionalContractParts(Map).- Parameters:
contractPartPaths- A map that contains all additional contract part paths.- Returns:
- The builder, for a fluent interface.
-
putAdditionalContractPart
Puts an additional contract part that is referenced by the main contract. This method can be called multiple times to add multiple referenced additional contract parts.- Parameters:
ref- The unique reference of the additional contract part.contractPart- The additional contract part.- Returns:
- The builder, for a fluent interface
-
setAdditionalContractParts
Uses the additional contract parts from the provided map to resolve referenced additional contract parts. Replaces all previously put additional contract parts byputAdditionalContractPart(String, JsonObject). If the same reference is used also replaces the additional contract part paths added byputAdditionalContractPartPath(String, String)orsetAdditionalContractPartPaths(Map).- Parameters:
contractParts- A map that contains additional contract parts.- Returns:
- The builder, for a fluent interface.
-
mediaTypeRegistry
-
build
-