Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

How to create payload body without trailing newline #56

Closed
netmilk opened this issue Oct 31, 2013 · 3 comments
Closed

How to create payload body without trailing newline #56

netmilk opened this issue Oct 31, 2013 · 3 comments
Labels

Comments

@netmilk
Copy link

netmilk commented Oct 31, 2013

Hi,

I can't find out how to describe / express response payload body in the API Blueprint format without trailing newline in the result AST. I'm trying both fenced and normal syntax for the code block without any success. I need to express response body precisely because I'm testing the backend API with Dredd and this issue brakes my tests.

My blueprint is here and the snowcrash output is:

OK.
warning: (3)  message-body content is expected to be a pre-formatted code block, separate it by an empty line and indent every of its line by at least 4 spaces or 1 tab :61:6

_version: 1.0
metadata:
name: My API
description:
resourceGroups:
- name:
  description:
  resources:
  - name: Fish
    description:
    uriTemplate: /fish
    model:
    parameters:
    headers:
    actions:
    - name: Catch
      description:
      method: GET
      parameters:
      headers:
      examples:
      - name:
        description:
        requests:
        responses:
        - name: 404
          description:
          headers:
          body: "Whip!\n"
          schema:
    - name: Release
      description:
      method: DELETE
      parameters:
      headers:
      examples:
      - name:
        description:
        requests:
        responses:
        - name: 404
          description:
          headers:
          body: "Blam...\n"
          schema:
@zdne
Copy link
Contributor

zdne commented Oct 31, 2013

@netmilk

I am afraid the only option at the moment is to eat one the trailing new line manually (as Apiary does). This is the limitation caused by the Makrdown syntax for pre formatted code block.

Snow Crash could remove one trailing new line but then the problem would be opposite – what if you need your message-body with a new line?

Any suggestion welcomed!

@netmilk
Copy link
Author

netmilk commented Jul 1, 2014

I think Snowcrash should remove last trailing newline added by the sundown parser and to have explicitly add trailing new-line if you want it in the message-body. It's the same like text editors does it.

@zdne
Copy link
Contributor

zdne commented Jul 8, 2014

As per our discussion with @netmilk We have agreed that there would be no good solution to address this on the parser-side. I will close this issue with pointing to the subject of it as a parser behavior

Assets and trailing new lines

According to the original markdown specification pre-formatted blocks are recognized produced by indenting every line of the block by at least 4 spaces or 1 tab.

    code block

In a GFM extension using backticks:

```
code block
```

However from a markdown perspective this always results in a string with a trailing new line – code block\n. For a Snow Crash user (tooling) it is safe to assume that there is always at least one trailing new line in an asset being parsed.

However from the user input Snow Crash can't make assumptions whether this newline is intentional or given by the Markdown syntax requirements. For these reasons Snow Crash leaves up to the tooling to consider (and strip) whether the newline should be stripped.

Note: The intent could be expressed in a future using external assets.

@zdne zdne closed this as completed Jul 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants