Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underscores in attribute names #224

Closed
mootpointer opened this issue Jul 7, 2015 · 4 comments
Closed

Underscores in attribute names #224

mootpointer opened this issue Jul 7, 2015 · 4 comments

Comments

@mootpointer
Copy link

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.

@pksunkara
Copy link
Contributor

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

@kamihouse
Copy link

Guys we can do this:

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

Works great!

@dchirikov
Copy link

dchirikov commented Dec 28, 2018

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

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

@pksunkara
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants