Pollito Dev
December 30, 2023

Contract-Driven Development 3: Creation of contracts

Posted on December 30, 2023  •  2 minutes  • 392 words  • Other languages:  Español

Definition of contracts before getting our hands dirty.

Check the github repo

This is a continuation of Contract-Driven Development 2: Coming up with a practice scenario .

Everything we’ll do here, you can find in in the github repo.

Spring City Explorer - Backend: Branch feature/cdd-3

Little change in the naming of things

We are gonna rename everything related to “News” to “Article”. That’s cause news is a weird word that is a plural and singular on its own, and when talking about entities, we usually talk about a single entity, in singular. So, to ease of future understanding, we are doing that little change.

diagram

What contracts are we creating?

We need:

Feel free to save your OAS wherever, as long as it is inside main/resources/

So at the moment, that would be a total of three files.

contracts

I’m not gonna get into details on how to create an OAS. There’re plenty of resources out there to learn + chatGPT is decent at it, but usually runs a little bit short.

Creating the weatherstack.yaml and mediastack.yaml

Is about reading their respective docs, and doing the manual labor of writing the specification so it represents the desired behaviour. Maybe they have their specification.yaml files somewhere around, but I wasn’t able to find them.

Creating the springcityexplorer.yaml

It was divided in two steps:

Checking the end result

At the moment, our project looks like this file tree

Feel free to review each yaml file in your fav OAS editor. I’m using OpenAPI ​(Swagger)​ Editor , a Jetbrains plugin. But the most popular option nowadays is Swagger Editor .

Hey, check me out!

You can find me here