apiary

Apiary.io - multiple responses (200) with different parameters

拜拜、爱过 提交于 2019-11-30 18:11:19
I am trying to get different responses passing different parameters but something is not working. This is my API: ## Question [/questions/{question_id}] A Question object has the following attributes: + Parameters + question_id: `1` (number, required) - ID of the Question in form of an integer ### View a Questions Detail [GET] + Request + Header X-Custom-Header : 1 + Response 200 (application/json) { "id": "1", "name": "Marco" } + Request + Header X-Custom-Header : 2 + Response 200 (application/json) { "id: "2", "name": "Lucas" } But when calling /questions/1 or /questions/2 the response is

Trying to describe the request and response using Data Structures in API Blueprint

半世苍凉 提交于 2019-11-30 06:56:15
I'm trying to document an endpoint with API Blueprint, using the new Attributes and DataStructures sections of the spec. My request payload looks like this: { "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "sales", "version": "2.0" }, { "name": "products", "version": "2.0" } ] } My response payload looks something like that: { "data": { "id": "dc85058a-a683-11e4-ef46-e9431a15be8c", "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "products", "version": "2.0" }, { "name": "sales", "version": "2.0" } ] } } I tried the following API Blueprint

Apiary.io - multiple responses (200) with different parameters

妖精的绣舞 提交于 2019-11-30 03:03:16
问题 I am trying to get different responses passing different parameters but something is not working. This is my API: ## Question [/questions/{question_id}] A Question object has the following attributes: + Parameters + question_id: `1` (number, required) - ID of the Question in form of an integer ### View a Questions Detail [GET] + Request + Header X-Custom-Header : 1 + Response 200 (application/json) { "id": "1", "name": "Marco" } + Request + Header X-Custom-Header : 2 + Response 200

Trying to describe the request and response using Data Structures in API Blueprint

人盡茶涼 提交于 2019-11-29 08:04:45
问题 I'm trying to document an endpoint with API Blueprint, using the new Attributes and DataStructures sections of the spec. My request payload looks like this: { "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "sales", "version": "2.0" }, { "name": "products", "version": "2.0" } ] } My response payload looks something like that: { "data": { "id": "dc85058a-a683-11e4-ef46-e9431a15be8c", "url": "http://requestb.in/11v7i7e1", "active": true, "types": [ { "name": "products

How do I send a JSON string in a POST request in Go

妖精的绣舞 提交于 2019-11-27 05:48:10
I tried working with Apiary and made a universal template to send JSON to mock server and have this code: package main import ( "encoding/json" "fmt" "github.com/jmcvetta/napping" "log" "net/http" ) func main() { url := "http://restapi3.apiary.io/notes" fmt.Println("URL:>", url) s := napping.Session{} h := &http.Header{} h.Set("X-Custom-Header", "myvalue") s.Header = h var jsonStr = []byte(` { "title": "Buy cheese and bread for breakfast." }`) var data map[string]json.RawMessage err := json.Unmarshal(jsonStr, &data) if err != nil { fmt.Println(err) } resp, err := s.Post(url, &data, nil, nil)

How do I send a JSON string in a POST request in Go

笑着哭i 提交于 2019-11-26 11:45:14
问题 I tried working with Apiary and made a universal template to send JSON to mock server and have this code: package main import ( \"encoding/json\" \"fmt\" \"github.com/jmcvetta/napping\" \"log\" \"net/http\" ) func main() { url := \"http://restapi3.apiary.io/notes\" fmt.Println(\"URL:>\", url) s := napping.Session{} h := &http.Header{} h.Set(\"X-Custom-Header\", \"myvalue\") s.Header = h var jsonStr = []byte(` { \"title\": \"Buy cheese and bread for breakfast.\" }`) var data map[string]json