Swagger that defines how the credential issuer API should behave.
This is an API definition, the purpose is to ease the integration of the credential backend and frontend.
The code has been autogenerated from the swagger spec file as an example. Then the generated api has been modified to add some error cases.
Build the Docker image:
docker build -t credential-issuer-api .
Start the generated server:
docker run --rm -ti -p 8080:8080 credential-issuer-api
Run the following curl request (any DNI value except "invalid" or "500" will be accepted).
curl -X POST \
http://localhost:8080/issue-credential \
-H 'Content-Type: application/json' \
-d '{
"dni": "12345678A"
}'
The response should be:
{
"credential": "1234567890"
}
Pass the string "invalid" as DNI to test this case.
curl -X POST \
http://localhost:8080/issue-credential \
-H 'Content-Type: application/json' \
-d '{
"dni": "invalid"
}'
The response should be:
{
"error": "The specified ID is not valid"
}
Pass the string "500" as DNI to test this case.
curl -X POST \
http://localhost:8080/issue-credential \
-H 'Content-Type: application/json' \
-d '{
"dni": "500"
}'
The response should be:
{
"error": "There was an error while issuing the credential"
}