Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
12.89k stars 482 forks source link

Allow types in fenced content of request bodies #1117

Open tpluscode opened 1 year ago

tpluscode commented 1 year ago

Problem to solve

To get some syntax support in request bodies I noticed that I can have my IDE (intellij) to recognise known file types as I would in markdown

POST /endpoint
```sparql
Syntax support here \o/


Unfortunately, at least in version 1.8.2, the word `sparql` is included as part of the body

### Proposal

Would it be as simple as ignoring trailing characters after the opening triple backtick?
jcamiel commented 1 year ago

Hi @tpluscode we've changed the syntax for the incoming 2.0.0, to support GraphQL body type (see #1000):

POST https://foo.com/graphql
```graphql
query {
  user
}
```

For the moment, I think we make a parsing error if the type is anything apart json, xml, graphql. We may be considering support any string here, or having a broader white list. What do you think @fabricereix?

fabricereix commented 1 year ago

Maybe we should indeed accept any string to be used as doc. If it is really used by Hurl to create a specific body (such as graphql) we could log it in verbose mode.