Api-blueprint: Underscores in attribute names

Created on 7 Jul 2015  路  4Comments  路  Source: apiaryio/api-blueprint

If an underscore is both in an Attribute name and its example value, the parser treats the whole line as the attribute name with a null value.

For example this blueprint:

# GET /message
+ Response 200 (text/plain)
        + Attributes
            + some_thing: an_example_thing

Parsed by Drafter results in this:

_version: "3.0"
metadata: []
name: ""
description: ""
element: "category"
resourceGroups:
  -
    name: ""
    description: ""
    resources:
      -
        element: "resource"
        name: ""
        description: ""
        uriTemplate: "/message"
        model: {}
        parameters: []
        actions:
          -
            name: ""
            description: ""
            method: "GET"
            parameters: []
            attributes:
              relation: ""
              uriTemplate: ""
            content: []
            examples:
              -
                name: ""
                description: ""
                requests: []
                responses:
                  -
                    name: "200"
                    description: ""
                    headers:
                      -
                        name: "Content-Type"
                        value: "text/plain"
                    body: ""
                    schema: ""
                    content:
                      -
                        element: "dataStructure"
                        name: null
                        typeDefinition:
                          typeSpecification:
                            name: null
                            nestedTypes: []
                          attributes: []
                        sections:
                          -
                            class: "memberType"
                            content:
                              -
                                content:
                                  name:
                                    literal: "some_thing: an_example_thing"
                                  description: ""
                                  valueDefinition:
                                    values: []
                                    typeDefinition:
                                      typeSpecification:
                                        name: null
                                        nestedTypes: []
                                      attributes: []
                                  sections: []
                                class: "property"
        content: []
content:
  -
    element: "category"
    content:
      -
        element: "resource"
        name: ""
        description: ""
        uriTemplate: "/message"
        model: {}
        parameters: []
        actions:
          -
            name: ""
            description: ""
            method: "GET"
            parameters: []
            attributes:
              relation: ""
              uriTemplate: ""
            content: []
            examples:
              -
                name: ""
                description: ""
                requests: []
                responses:
                  -
                    name: "200"
                    description: ""
                    headers:
                      -
                        name: "Content-Type"
                        value: "text/plain"
                    body: ""
                    schema: ""
                    content:
                      -
                        element: "dataStructure"
                        name: null
                        typeDefinition:
                          typeSpecification:
                            name: null
                            nestedTypes: []
                          attributes: []
                        sections:
                          -
                            class: "memberType"
                            content:
                              -
                                content:
                                  name:
                                    literal: "some_thing: an_example_thing"
                                  description: ""
                                  valueDefinition:
                                    values: []
                                    typeDefinition:
                                      typeSpecification:
                                        name: null
                                        nestedTypes: []
                                      attributes: []
                                  sections: []
                                class: "property"
        content: []

Similarly, this is mis-parsed by Apiary, and is syntax highlighted incorrectly.

Question

Most helpful comment

Hey, If you read the MSON spec, you can see that _ is a reserved character. Please use backticks to escape the whole word. Here is an example:

+ `some_thing`: `an_example_thing`

Please note that there is an UX improvement planned at #210

All 4 comments

Hey, If you read the MSON spec, you can see that _ is a reserved character. Please use backticks to escape the whole word. Here is an example:

+ `some_thing`: `an_example_thing`

Please note that there is an UX improvement planned at #210

Guys we can do this:

+ Parameters
     + `grant_type`: `refresh_token` (string, required) - Tipo de concess茫o

Works great!

Seems not really. If both parameter and value have underscores, JSON is being rendered incorrectly. Like

+ aaa_bbb: `ccc_ddd` (string, required) - Example

Yes, in that case, you need to surround aaa_bbb with `

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zatziky picture zatziky  路  4Comments

basickarl picture basickarl  路  7Comments

spark-developer picture spark-developer  路  12Comments

fh-thudson picture fh-thudson  路  3Comments

agougousis picture agougousis  路  8Comments