Api-blueprint: Conditional parameters based on another parameter's value

Created on 29 Jun 2016  路  2Comments  路  Source: apiaryio/api-blueprint

What is the format for parameters if I have condition where some parameters can be changed based on another param's value. Eg: I have payment methods: paypal, bank transfer, etc.

  • + amount (required, number,1200) ... charge amount
  • + method (required, string,paypal) ... payment method

    • + Values

    • + paypal

    • + bank transfer

    • + etc

if method's value is "paypal", then my service need additional param:

if method's value is "bank transfer", then my service need additional params:

  • + bank_name (required, string,Panama National Bank) ... user's bank
  • + bank_account (required, number,3445315-XXX) ... user's bank account
Duplicate

Most helpful comment

Hi @pararang,

This isn't possible at the moment, but it is something on our radar and in our roadmap. We're planning to make parameters use MSON, which would allow you to use one of which should allow you to achieve this.

+ Parameters
    + amount: 1200 (number) - Charge Amount
    + One Of
        + Properties
            + method: paypal (required, fixed)
            + email (required)
        + Properties
            + method: bank (required, fixed)
            + `bank_name` (required)
            + `bank_account` (required)

screen shot 2016-06-29 at 10 49 52

Please track this in https://github.com/apiaryio/api-blueprint-rfcs/pull/3 / https://github.com/apiaryio/api-blueprint/issues/286

All 2 comments

Hi @pararang,

This isn't possible at the moment, but it is something on our radar and in our roadmap. We're planning to make parameters use MSON, which would allow you to use one of which should allow you to achieve this.

+ Parameters
    + amount: 1200 (number) - Charge Amount
    + One Of
        + Properties
            + method: paypal (required, fixed)
            + email (required)
        + Properties
            + method: bank (required, fixed)
            + `bank_name` (required)
            + `bank_account` (required)

screen shot 2016-06-29 at 10 49 52

Please track this in https://github.com/apiaryio/api-blueprint-rfcs/pull/3 / https://github.com/apiaryio/api-blueprint/issues/286

+1
One Of for Parameters would be very useful. I need it right now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bazo picture bazo  路  8Comments

Perni1984 picture Perni1984  路  6Comments

fh-thudson picture fh-thudson  路  3Comments

robbinjanssen picture robbinjanssen  路  6Comments

pete001 picture pete001  路  6Comments