ducin ducin - 6 days ago 6
reST (reStructuredText) Question

POST parameters support in RAML

I'd like to ask if there is any support for POST parameters in RAML. And if there is - what is the syntax. I've browsed spec 0.8 and spec 1.0 roughly (actually I'm bound to

0.8
, since many tools don't support
1.0
yet). I didn't find POST parameters support, but maybe I just missed something.

So what do I mean by POST parameters? These can be either of the two (sorry, I don't know their formal names, if there are any):


  • HTTP plain parameters,
    key=value
    , each parameter in one line, such as

    name=John Doe
    amount=5
    which is not really handy (e.g. no nesting)

  • parameters as JSON object, just a JSON with all its syntax allowed (server-side needs to parse this json); such as:

    {"name":"John Doe","amount":"5"}



Different server-side API implementations use either 1st or 2nd one. Anyway, how does RAML support these?

Answer

@Pedro has covered option 2, so here is option 1. Based on the discussion in the comments, it seems the encoding used is application/x-www-form-urlencoded.

You need to use formParameters.

Example:

  post:
    description: The POST operation adds an object to a specified bucket using HTML forms.
    body:
      application/x-www-form-urlencoded:
        formParameters:
          AWSAccessKeyId:
            description: The AWS Access Key ID of the owner of the bucket who grants an Anonymous user access for a request that satisfies the set of constraints in the Policy.
            type: string
          acl:
            description: Specifies an Amazon S3 access control list. If an invalid access control list is specified, an error is generated.
            type: string

Reference: https://github.com/raml-org/raml-spec/blob/master/raml-0.8.md#web-forms

Comments