Skip to content

spring-cloud-samples/spring-cloud-contract-nodejs-external-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Common contracts repo

This repo contains all contracts for apps in the system. Used by the https://github.com/spring-cloud-samples/spring-cloud-contract-nodejs example.

As a consumer

You are working offline in order to play around with the API of the producer. What you need to do is to have the producer’s stubs installed locally. To do that you have to (from the root of the repo)

cd src/main/resources/contracts/com/example/bookstore
mvn clean install -DskipTests

Then if you do ls ./target you’ll see bookstore-0.0.1-SNAPSHOT-stubs.jar. This jar will contain the stubs generated from your contracts. That way you can reference the com.example:boookstore:+:stubs dependency in your consumer tests.

As a producer

Assuming that the consumers have filed a PR with the proposed contract the producers can work offline to generate tests and stubs. To work offline, as a producer you just have to go to the root folder of the contracts and:

./mvnw clean install -DskipTests

Then if you do ls ./target you’ll see external-contracts-0.0.1-SNAPSHOT.jar. This file contains all DSL contracts, for all applications.

Now the producer can include the external-contracts-0.0.1-SNAPSHOT.jar from your local maven repository. You can achieve that by setting the proper flag in plugin properties.

Example for Maven

<plugin>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-contract-maven-plugin</artifactId>
    <configuration>
        <!-- url not required for working locally -->
        <contractsWorkOffline>true<contractsWorkOffline>
        <contractDependency>
            <groupId>com.example</groupId>
            <artifactId>external-contracts</artifactId>
        </contractDependency>
    </configuration>
</plugin>

and for Gradle:

contracts {
    contractsWorkOffline = true
    contractDependency {
        stringNotation = "com.example:external-contracts"
    }
}

About

External contracts for the Spring Cloud Contract NodeJS sample

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages