cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.
Apache License 2.0
766 stars 214 forks source link

Translate the Swagger API specification into a Servant API specification. #53

Closed jonathanknowles closed 5 years ago

jonathanknowles commented 5 years ago

Context

We intend to maintain both a Swagger API specification and a Servant API specification, and to keep the two in synchronization with one another.

Task

Translate the Swagger API specification (specifications/api/swagger.yaml) into an equivalent Servant API specification, including:

Acceptance Criteria

  1. Our Servant API must satisfy the Swagger API specification. Clients generated by the official Swagger Codegen tool should be able to connect and make API calls without issues.
  2. Endpoints defined in the Servant API may include specifications of errors that may be thrown.

Development Plan

PR

PR Base
#76 master
#107 master
#108 master
#119 master
#123 master
#124 master
#125 master
#128 master

QA

jonathanknowles commented 5 years ago

We also need to think about how we'll test that the Servant API is equivalent to the Swagger API specification.

KtorZ commented 5 years ago

@jonathanknowles On that last remark, I'd recommend looking into:

https://hackage.haskell.org/package/servant-swagger-1.1.7/docs/Servant-Swagger-Test.html#v:validateEveryToJSON

with some inspiration from (https://github.com/input-output-hk/cardano-wallet-legacy/blob/develop/test/unit/API/SwaggerSpec.hs)

And maybe later, give a shot to https://hackage.haskell.org/package/servant-quickcheck-0.0.2.2/docs/Servant-QuickCheck.html later on might be a good idea.

KtorZ commented 5 years ago

@jonathanknowles let's tackle generation of golden tests in a separate ticket (I'll explain tomorrow in the planning meeting).

piotr-iohk commented 5 years ago

@jonathanknowles, @KtorZ - really nice sets of tests for this. I like :+1:

Looking at coveralls there are few places where some cases could be produced:

What do you think?

KtorZ commented 5 years ago

I admit I don't full understand the third one :thinking: ... But I'll look into them all :+1:

piotr-iohk commented 5 years ago

Also this one seems weird -> https://coveralls.io/builds/22429878/source?filename=src/Cardano/Wallet/Api/Types.hs#L388 since eitherToParser is used in other places (e.g. https://coveralls.io/builds/22429878/source?filename=src/Cardano/Wallet/Api/Types.hs#L279).

Anyway, I'll put back to in progress for the time being.

KtorZ commented 5 years ago

For eitherToParser, I suspect lazyness is at play here. The other one seems to be an unused option from our serialization option. Will remove.

piotr-iohk commented 5 years ago

lgtm :+1: