LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

inconsistent description/string handling #60

Closed j-q-arnold closed 4 years ago

j-q-arnold commented 4 years ago

When reslang generates yaml, it uses inconsistent treatment for the description strings. This causes trouble in the various translations: reslang, yaml, markdown, swagger, html. OpenAPI accepts markdown in the description text. In-line markdown seems to survive reslang ok, but markdown that relies on the start-of-line positioning, such as an example block, doesn't seem to work.

liveandrew commented 4 years ago

hmm interesting - i didn't realize openapi could have markdown in it. i'll have a look at what's going wrong with the translation into yaml. thanks for the details example, it really helps!

liveandrew commented 4 years ago

have fixed this in this way:

  1. doc comments now indent based on the 2nd line of text

e.g. "this is a fine comment don't you think james "

will have the first 8 characters of each line stripped off. they will also have the training newline removed

note also that this: " This comment is great"

will have the leading comment removed

finally note that something like this: "This is some code here it comes:

                                                              class Foo {}

"

is still possible via relative indentation of 4 chars

liveandrew commented 4 years ago

some other observations:

  1. "block treatment varies: >, |, |-. I suggest using the same treatment for all descriptions, so the reslang author can expect consistent treatment."

this is the yaml formatter and all formatting options are legal in the yaml syntax. it's >- btw. i have no way to force this into a single construct, but i'm genuinely perplexed why we need this given it's just json and it renders fine in swagger

  1. "Descriptions formatted with > have extra linefeeds in the yaml. The raw text is double-spaced"

Yes - again, this is yaml syntax with correct treatment. See here for the various options for string encoding: https://symfony.com/doc/current/components/yaml/yaml_format.html#strings

are we having the need to parse these files by hand? all yaml parsers should handle the current representations with no problems