Api-blueprint: Problem with attribute values

Created on 29 Apr 2015  路  6Comments  路  Source: apiaryio/api-blueprint

I'm trying to define an attribute with a value that is a GUID, but I don't seem to find the way to properly express this:

  • Attributes (object)

    • uuid: 08ff7052-2e95-11e3-a1fc-000c294eede0 (guid) - Unique ID

    • date: 2014-07-14T12:03:20z (date) - A date

When doing the above, the parser seems to cut the definition on the first "-", which means that the first portion of the string is considered the example value (e.g., "08ff7052") and the second portion is considered to be part of the description (e.g., "2e95-11e3-a1fc-000c294eede0 (guid) - Unique ID")

I'm probably doing something wrong... can you point me in the right direction?

Question

Most helpful comment

When a literal contains reserved characters such as - it needs to be wrapped in backticks. See reserved characters & keywords.

It should look something like the following:

+ Attributes (object)
    + uuid: `08ff7052-2e95-11e3-a1fc-000c294eede0` (guid) - Unique ID
    + date: `2014-07-14T12:03:20z` (date) - A date

All 6 comments

When a literal contains reserved characters such as - it needs to be wrapped in backticks. See reserved characters & keywords.

It should look something like the following:

+ Attributes (object)
    + uuid: `08ff7052-2e95-11e3-a1fc-000c294eede0` (guid) - Unique ID
    + date: `2014-07-14T12:03:20z` (date) - A date

Thanks, that did part of the trick... but it also seems I can't define custom data types (e.g., "guid" or "date"), since I also get an error when doing that.

@jmdacruz You would need to declare them in the Data Structures section. Such as the following:

+ Attributes (object)
    + uuid: `08ff7052-2e95-11e3-a1fc-000c294eede0` (guid) - Unique ID
    + date: `2014-07-14T12:03:20z` (date) - A date

# Data Structures
## guid (string)
## date (string)

Doh! thanks, I had missed that. Is there a way to attach regular expressions to these user-defined data structures? If not, it might be a nice-to-have.

@jmdacruz You could provide custom Schema section and use JSON Schema's regular expressions. In the future, we consider to have Validations right in the user-defined data structures.

Great, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Perni1984 picture Perni1984  路  6Comments

annappropriate picture annappropriate  路  5Comments

robbinjanssen picture robbinjanssen  路  6Comments

alronlam picture alronlam  路  4Comments

bennettellis picture bennettellis  路  7Comments