Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Confusing AST for enum examples #734

@goganchic

Description

@goganchic

Suppose such doc:

# My API

# Data Structures

# Plan

+ kind (string)
    + Sample: free

Drafter generates such AST for samples section

                        samples:
                          element: "array"
                          content:
                            -
                              element: "string"
                              content: "free"

It's logically correct: samples for string element is an array of strings.

Suppose such doc:

# My API

# Data Structures

# Plan

+ kind (enum)
    + free
    + premium
    + Sample: free

Drafter generates such AST for samples section:

...
                        samples:
                          element: "array"
                          content:
                            -
                              element: "enum"
                              content:
                                element: "string"
                                attributes:
                                  typeAttributes:
                                    element: "array"
                                    content:
                                      -
                                        element: "string"
                                        content: "fixed"
                                content: "free"

I think element: "enum" is incorrect in this case. Samples for such enum should be strings from the set "free", "premium", but not a new enum type which contains single string element. So in my opinion correct sample should be something like:

                        samples:
                          element: "array"
                          content:
                            -
                              element: "string"
                              content: "free"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions