0

I would be very thankful if someone could tell me if I can describe a string in Data Structures, because what I'm writing (in the sample below) doesn't work as it should. "Date" and "Point" are repeated a lot of times in different responses through my document, that's why I thought about taking it to the Data Structures. Is it even possible to get not an object but a string in this situation?

+ Response 200 (application/json)
    + Attributes
        + Date (Date)
        + Point (Point)
        + id: 123 (number)

# Data Structures 

## Date 
+ Date: `01.01.2019` (string) - or "2019-01-01"

## Point
+ Point: `(35.7545174,38.9170445)` (string)

This gives me the following structure in the Body:

{
    "Date": {
              "Date": "01.01.2019"
    },
    "Point": {
              "Point": "(35.7545174,38.9170445)"
    },
    "id": 123
}

But I need this:

{
    "Date": "01.01.2019",
    "Point": "(35.7545174,38.9170445)",
    "id": 123
}
Nana
  • 1
  • 1

1 Answers1

1

you need to define Date and Point as a string:

## Date (string)

Here is your example fixed:

FORMAT: 1A

# Stackoverflow 60415996

## Path [/]

### Verb [GET]

+ Response 200 (application/json)
    + Attributes
        + Date (Date)
        + Point (Point)
        + id: 123 (number)

# Data Structures 

## Date (string)

### Sample

2019-05-12T04:55:00-01

### Sample

01.01.2019

### Sample

2019-01-01

## Point (string)

### Sample

(35.7545174,38.9170445)

Here is a result: https://stackoverflow60415996.docs.apiary.io/

You can find a lot of examples in https://github.com/apiaryio/mson and https://github.com/apiaryio/mson-zoo/

Ondrej
  • 136
  • 3
  • Thanks a lot! And is it okay that in Body it looks like "2019-05-12T04:55:00-01\n\n" with those \n\n? – Nana Feb 26 '20 at 15:36
  • That's unfortunately a bug in the API Blueprint parser Drafter (tracked at https://github.com/apiaryio/drafter/issues/607) – kylef Feb 26 '20 at 15:51