天道酬勤,学无止境

apiary

Create Mock Service API using Apiary

I'm attempting to create mock api services for testing purposes. We are already using Apiary on another team so I'm starting there. So far, I've noticed that if I want to have two separate calls requires mocking out of both requests. For example to get the notes with ids 1 and 2 requires explicitly writing out responses like: /notes/1 /notes/2 Is there a way to avoid this? Admittedly I'm still ramping up on creating blueprints.

2021-06-12 05:34:17    分类:问答    apiblueprint   apiary.io   apiary

Represent File Uploads in API Blueprints

We have an API end point where an image file can be uploaded along with the name of the file (a string) as well as a description (string). Apiary / API Blueprints won't allow me to have something like: + Request (multipart/form-data) + Headers Authorization: [key] + Attributes + name (string, required) - A human-readable name of the Catalog Item + description (string, optional) - A human readable description of the Catalog Item + image (file, optional) - An image file corresponding to the Catalog Item I get: base type 'file' is not defined in the document Is there a way to represent multipart

2021-06-10 13:23:41    分类:问答    apiblueprint   apiary.io   apiary

如何在Go中的POST请求中发送JSON字符串(How do I send a JSON string in a POST request in Go)

问题 我尝试使用Apiary,并制作了一个通用模板以将JSON发送到模拟服务器并具有以下代码: 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) if err != nil { log.Fatal(err) } fmt.Println("response

2021-04-10 05:04:59    分类:技术分享    json   rest   go   apiary

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

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)

2021-03-29 04:14:25    分类:问答    json   rest   go   apiary