Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servant Swagger QuickCheck Property Testing (validateEveryJSON & validateEveryPath) #108

Merged
merged 2 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cardano-wallet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,24 @@ test-suite unit
, containers
, deepseq
, exceptions
, file-embed
, fmt
, generic-arbitrary
, hspec
, hspec-golden-aeson
, lens
, memory
, process
, QuickCheck
, quickcheck-instances
, servant-server
, servant-swagger
, swagger2
, text
, time-units
, transformers
, uuid-types
, yaml
type:
exitcode-stdio-1.0
hs-source-dirs:
Expand Down
236 changes: 119 additions & 117 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -370,127 +370,128 @@ networkInformationSoftwareUpdate: &networkInformationSoftwareUpdate

#############################################################################
# #
# RESOURCES #
# DEFINITIONS #
# #
#############################################################################

address: &address
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming you have just relocated and polished a few things here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I actually forgot about this while writing the spec file but, Swagger expects "definitions" of model / resources to be located in a "definitions" properties from the root swagger file. So I just moved things to be located under this field.

type: object
required:
- id
- state
properties:
id: *addressId
state: *addressState

networkInformation: &networkInformation
type: object
required:
- blockchainHeight
- localHeight
- ntpStatus
- software_update
- syncProgress
- tip
properties:
blockchainHeight: *networkInformationBlockchainHeight
localHeight: *networkInformationLocalHeight
ntpStatus: *networkInformationNtpStatus
software_update: *networkInformationSoftwareUpdate
syncProgress: *networkInformationSyncProgress
tip: *networkInformationTip

stakePool: &stakePool
type: object
required:
- id
- ticker
- metrics
- profit_margin
properties:
id: *stakePoolId
ticker: *stakePoolTicker
metrics: *stakePoolMetrics
profit_margin: *stakePoolProfitMargin
definitions:
Address: &address
type: object
required:
- id
- state
properties:
id: *addressId
state: *addressState

transaction: &transaction
type: object
required:
- id
- amount
- depth
- direction
- inputs
- outputs
- status
properties:
id: *transactionId
amount: *transactionAmount
inserted_at: *transactionInsertedAt
depth: *transactionDepth
direction: *transactionDirection
inputs: *transactionInputs
outputs: *transactionOutputs
status: *transactionStatus

wallet: &wallet
type: object
required:
- id
- address_pool_gap
- balance
- delegation
- name
- passphrase
- state
properties:
id: *walletId
address_pool_gap: *walletAddressPoolGap
balance: *walletBalance
delegation: *walletDelegation
name: *walletName
passphrase: *walletPassphraseInfo
state: *walletState
NetworkInformation: &networkInformation
type: object
required:
- blockchainHeight
- localHeight
- ntpStatus
- software_update
- syncProgress
- tip
properties:
blockchainHeight: *networkInformationBlockchainHeight
localHeight: *networkInformationLocalHeight
ntpStatus: *networkInformationNtpStatus
software_update: *networkInformationSoftwareUpdate
syncProgress: *networkInformationSyncProgress
tip: *networkInformationTip

StakePool: &stakePool
type: object
required:
- id
- ticker
- metrics
- profit_margin
properties:
id: *stakePoolId
ticker: *stakePoolTicker
metrics: *stakePoolMetrics
profit_margin: *stakePoolProfitMargin

walletUTxOsStatistics: &walletUTxOsStatistics
type: object
required:
- total
- scale
- distribution
properties:
total: *amount
scale:
type: string
enum:
- log10
distribution:
type: object
additionalProperties:
type: integer
example:
total:
quantity: 42000000
unit: lovelace
scale: log10
distribution:
10: 1
100: 0
1000: 8
10000: 14
100000: 32
1000000: 3
10000000: 0
100000000: 12
1000000000: 0
10000000000: 0
100000000000: 0
1000000000000: 0
10000000000000: 0
100000000000000: 0
1000000000000000: 0
10000000000000000: 0
45000000000000000: 0
Transaction: &transaction
type: object
required:
- id
- amount
- depth
- direction
- inputs
- outputs
- status
properties:
id: *transactionId
amount: *transactionAmount
inserted_at: *transactionInsertedAt
depth: *transactionDepth
direction: *transactionDirection
inputs: *transactionInputs
outputs: *transactionOutputs
status: *transactionStatus

Wallet: &wallet
type: object
required:
- id
- address_pool_gap
- balance
- delegation
- name
- passphrase
- state
properties:
id: *walletId
address_pool_gap: *walletAddressPoolGap
balance: *walletBalance
delegation: *walletDelegation
name: *walletName
passphrase: *walletPassphraseInfo
state: *walletState

WalletUTxOsStatistics: &walletUTxOsStatistics
type: object
required:
- total
- scale
- distribution
properties:
total: *amount
scale:
type: string
enum:
- log10
distribution:
type: object
additionalProperties:
type: integer
example:
total:
quantity: 42000000
unit: lovelace
scale: log10
distribution:
10: 1
100: 0
1000: 8
10000: 14
100000: 32
1000000: 3
10000000: 0
100000000: 12
1000000000: 0
10000000000: 0
100000000000: 0
1000000000000: 0
10000000000000: 0
100000000000000: 0
1000000000000000: 0
10000000000000000: 0
45000000000000000: 0


#############################################################################
Expand Down Expand Up @@ -588,7 +589,8 @@ parametersQuitStakePool: &parametersQuitStakePool

responsesErr: &responsesErr
type: object
required: message
required:
- message
properties:
message:
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/Cardano/Wallet/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Api = DeleteWallet :<|> GetWallet :<|> ListWallets

type DeleteWallet = "wallets"
:> Capture "walletId" WalletId
:> Delete '[JSON] NoContent
:> Delete '[] NoContent

type GetWallet = "wallets"
:> Capture "walletId" WalletId
Expand Down
Loading