alvessteve / fizzbuzz-rest-api

Simple REST-API example
1 stars 1 forks source link
rest-api spring-boot

Fizzbuzz REST API

Enoncé

Write a simple fizz-buzz REST server.

The original fizz-buzz consists in writing all numbers from 1 to 100, and just replacing all multiples of 3 by "fizz", all multiples of 5 by "buzz", and all multiples of 15 by "fizzbuzz". The output would look like this: " 1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizzbuzz,16,...".

Your goal is to implement a web server that will expose a REST API endpoint that:

Accepts five parameters : three integers int1, int2 and limit, and two strings str1 and str2.

Returns a list of strings with numbers from 1 to limit, where: all multiples of int1 are replaced by str1, all multiples of int2 are replaced by str2, all multiples of int1 and int2 are replaced by str1str2.

The server needs to be:

Ready for production

Easy to maintain by other developers

This endpoint should:

Don’t forget to add unit tests.

Please commit your project on Git and send me the url.

Stack

API

Les endpoints sont:

The project embarks the springdoc-openapi-ui dependency, so a swagger page is reachable at this page http://localhost:8080/swagger-ui.html.

Install & run

Build the project:

./gradlew build

The project can be dockerized via

./gradlew clean bootBuildImage

and then run:

docker-compose up

Remarques

Misc

On MacOS 12.6, docker does not create docker.sock file, preventing docker to run smoothly: in that case please do:

sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock