Search code examples
odataopenapi

OpenAPI - How to document parameters that should be of type 'function', like OData's $apply


I am trying to document an OData query parameter with OpenAPI.
It looks something like this:

$apply=aggregate(Amount with sum as Total)

I am not expecting much, but I would like OpenAPI to at least check that the caller is restricted to a function name aggregate.

Are there any options here?


Solution

  • I think I figured out how using string patterns:

    "schema": {
      "type": "string",
      "pattern": "^aggregate\\([a-zA-Z0-9_]* with (sum|min|max|average)\\)$"
    }
    

    By using RegEx one could possibly support all of the complexities of OData.

    I wish something like that would have been posted here:
    http://docs.oasis-open.org/odata/odata-openapi/v1.0/odata-openapi-v1.0.html