apiaryio / drafter

API Blueprint Parser (C++)
https://apiblueprint.org/
MIT License
301 stars 54 forks source link

Allow type attributes in Mixins #370

Open pksunkara opened 8 years ago

pksunkara commented 8 years ago

fixed, required and optional are allowed for mixin definitions.

Input

# Data Structures
# A 
+ a: a

# B
+ b: b
+ Include (A, optional)

Output

element: "parseResult"
content:
  -
    element: "category"
    meta:
      classes:
        - "api"
      title: ""
    content:
      -
        element: "category"
        meta:
          classes:
            - "dataStructures"
        content:
          -
            element: "dataStructure"
            content:
              -
                element: "object"
                meta:
                  id: "A"
                content:
                  -
                    element: "member"
                    content:
                      key:
                        element: "string"
                        content: "a"
                      value:
                        element: "string"
                        content: "a"
          -
            element: "dataStructure"
            content:
              -
                element: "object"
                meta:
                  id: "B"
                content:
                  -
                    element: "member"
                    content:
                      key:
                        element: "string"
                        content: "b"
                      value:
                        element: "string"
                        content: "b"
                  -
                    element: "ref"
                    content:
                      href: "A"
                      path: "content"

Expected

There should typeAttributes: ["optional"] somewhere in there.

kylef commented 7 years ago

According to MSON specification, ( and ) are not used for included mixins at all. The syntax is + Include A not + Include (A). No type attributes are permitted. We should make the parser stricter.

screen shot 2017-09-01 at 15 07 15

pksunkara commented 7 years ago

What? Type Definition is allowed according to your own screenshot. Type Definition contains Type Attributes. This has been like this since the beginning.