Files
spring-cloud-contract/docs/modules/ROOT/pages/project-features-contract/_dsl-http-top-level-elements.adoc
Marcin Grzejszczak 0159bcde09 Updated antora docs
2023-09-14 15:43:24 +02:00

48 lines
1.5 KiB
Plaintext

[[contract-dsl-http-top-level-elements]]
== HTTP Top-Level Elements
include::partial$_attributes.adoc[]
You can call the following methods in the top-level closure of a contract definition:
* `request`: Mandatory
* `response` : Mandatory
* `priority`: Optional
The following example shows how to define an HTTP request contract:
====
[source,groovy,indent=0,subs="verbatim",role="primary"]
.Groovy
----
include::{verifier_root_path}/src/test/groovy/org/springframework/cloud/contract/verifier/builder/ContractHttpDocsSpec.groovy[tags=http_dsl,indent=0]
----
[source,yml,indent=0,subs="verbatim",role="secondary"]
.YAML
----
include::{verifier_root_path}/src/test/resources/yml/contract.yml[tags=priority,indent=0]
include::{verifier_root_path}/src/test/resources/yml/contract.yml[tags=request,indent=0]
...
include::{verifier_root_path}/src/test/resources/yml/contract.yml[tags=response,indent=0]
...
----
[source,java,indent=0,subs="verbatim",role="secondary"]
.Java
----
include::{verifier_root_path}/src/test/resources/contractsToCompile/contract_docs_examples.java[tags=http_dsl,indent=0]
----
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
.Kotlin
----
include::{verifier_root_path}/src/test/resources/kotlin/contract_docs_examples.kts[tags=http_dsl,indent=0]
----
====
IMPORTANT: If you want to make your contract have a higher priority,
you need to pass a lower number to the `priority` tag or method. For example, a `priority` with
a value of `5` has higher priority than a `priority` with a value of `10`.