apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

Conditional parameters based on another parameter's value #339

Closed pararang closed 8 years ago

pararang commented 8 years ago

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.

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:

kylef commented 8 years ago

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

webmato commented 7 years ago

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