This is a simple example of how to use Spring Cloud Contract to create a contract between a Spring Boot 3 application (which is the Producer) and an Angular application (which is the Consumer).
We have created a simple application with Spring Boot 3 and Spring Cloud Contract.
- Go to the catalog folder
cd catalog
- Compile and package
mvn clean package
- Build Docker image with the stubs
docker build -f StubrunnerDockerfile --tag paradigmadigital/ecommerce-catalog-stubs .
We have created a simple Angular eCommerce backend with integration tests that use stub runner as mock server.
- Go to the eCommerce folder
cd ecommerce
- Installs a package and any packages that it depends on
npm install
- Run the integration tests
npm run integration-tests
- Run the stub runner
docker run -d --rm --name ecommerce-catalog-stub-server -p 8080:8080 paradigmadigital/ecommerce-catalog-stubs
- Run the Angular project
npm start
-
Open in your browser the path http://localhost:4200/ to see the UI
-
Stop the stub runner
docker stop ecommerce-catalog-stub-server