mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Everything service has examples now, fixes for client generator (#203)
This commit is contained in:
28
address/examples.json
Normal file
28
address/examples.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"lookupPostcode": [
|
||||||
|
{
|
||||||
|
"title": "Lookup postcode",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"postcode": "SW1A 2AA"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"addresses": [
|
||||||
|
{
|
||||||
|
"line_one": "Prime Minister & First Lord Of The Treasury",
|
||||||
|
"line_two": "10 Downing Street",
|
||||||
|
"summary": "",
|
||||||
|
"organisation": "Prime Minister & First Lord Of The Treasury",
|
||||||
|
"building_name": "",
|
||||||
|
"premise": "10",
|
||||||
|
"street": "Downing Street",
|
||||||
|
"locality": "",
|
||||||
|
"town": "LONDON",
|
||||||
|
"county": "London",
|
||||||
|
"postcode": "SW1A 2AA"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -157,6 +157,138 @@ func TestTsGen(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTimeExample(t *testing.T) {
|
||||||
|
spec := &openapi3.Swagger{}
|
||||||
|
err := json.Unmarshal([]byte(timeExample), &spec)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(spec.Components.Schemas) == 0 {
|
||||||
|
t.Fatal("boo")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(spec.Components.Schemas)
|
||||||
|
res := schemaToGoExample("time", "NowRequest", spec.Components.Schemas, map[string]interface{}{
|
||||||
|
"location": "London",
|
||||||
|
})
|
||||||
|
if strings.TrimSpace(res) != strings.TrimSpace(timeExp) {
|
||||||
|
t.Log(res, timeExp)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(spec.Components.Schemas)
|
||||||
|
res = schemaToGoExample("time", "ZoneRequest", spec.Components.Schemas, map[string]interface{}{
|
||||||
|
"location": "London",
|
||||||
|
})
|
||||||
|
if strings.TrimSpace(res) != strings.TrimSpace(timeExp) {
|
||||||
|
t.Log(res, timeExp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeExample = `{
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
|
||||||
|
"NowRequest": {
|
||||||
|
"description": "Get the current time",
|
||||||
|
"properties": {
|
||||||
|
"location": {
|
||||||
|
"description": "optional location, otherwise returns UTC",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "NowRequest",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"NowResponse": {
|
||||||
|
"properties": {
|
||||||
|
"localtime": {
|
||||||
|
"description": "the current time as HH:MM:SS",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"description": "the location as Europe/London",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"description": "timestamp as 2006-01-02T15:04:05.999999999Z07:00",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"timezone": {
|
||||||
|
"description": "the timezone as BST",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"unix": {
|
||||||
|
"description": "the unix timestamp",
|
||||||
|
"format": "int64",
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "NowResponse",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"ZoneRequest": {
|
||||||
|
"description": "Get the timezone info for a specific location",
|
||||||
|
"properties": {
|
||||||
|
"location": {
|
||||||
|
"description": "location to lookup e.g postcode, city, ip address",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "ZoneRequest",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"ZoneResponse": {
|
||||||
|
"properties": {
|
||||||
|
"abbreviation": {
|
||||||
|
"description": "the abbreviated code e.g BST",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"country": {
|
||||||
|
"description": "country of the timezone",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"dst": {
|
||||||
|
"description": "is daylight savings",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"latitude": {
|
||||||
|
"description": "e.g 51.42",
|
||||||
|
"format": "double",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"localtime": {
|
||||||
|
"description": "the local time",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"description": "location requested",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"longitude": {
|
||||||
|
"description": "e.g -0.37",
|
||||||
|
"format": "double",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"region": {
|
||||||
|
"description": "region of timezone",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"timezone": {
|
||||||
|
"description": "the timezone e.g Europe/London",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "ZoneResponse",
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
const timeExp = `Location: London,
|
||||||
|
`
|
||||||
|
|
||||||
func TestExample(t *testing.T) {
|
func TestExample(t *testing.T) {
|
||||||
|
|
||||||
spec := &openapi3.Swagger{}
|
spec := &openapi3.Swagger{}
|
||||||
|
|||||||
@@ -70,7 +70,14 @@ func main() {
|
|||||||
return strings.Join(parts[1:len(parts)-1], "") + "Response"
|
return strings.Join(parts[1:len(parts)-1], "") + "Response"
|
||||||
},
|
},
|
||||||
"endpointComment": func(endpoint string, schemas map[string]*openapi3.SchemaRef) string {
|
"endpointComment": func(endpoint string, schemas map[string]*openapi3.SchemaRef) string {
|
||||||
comm := schemas[strings.Title(endpoint)+"Request"].Value.Description
|
v := schemas[strings.Title(endpoint)+"Request"]
|
||||||
|
if v == nil {
|
||||||
|
panic("can't find " + strings.Title(endpoint) + "Request")
|
||||||
|
}
|
||||||
|
if v.Value == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
comm := v.Value.Description
|
||||||
ret := ""
|
ret := ""
|
||||||
for _, line := range strings.Split(comm, "\n") {
|
for _, line := range strings.Split(comm, "\n") {
|
||||||
ret += "// " + strings.TrimSpace(line) + "\n"
|
ret += "// " + strings.TrimSpace(line) + "\n"
|
||||||
@@ -236,11 +243,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exam, err := ioutil.ReadFile(filepath.Join(workDir, serviceName, "examples.json"))
|
exam, err := ioutil.ReadFile(filepath.Join(workDir, serviceName, "examples.json"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m := map[string][]example{}
|
m := map[string][]example{}
|
||||||
err = json.Unmarshal(exam, &m)
|
err = json.Unmarshal(exam, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(string(exam), err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,7 +576,7 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op
|
|||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
var fieldSeparator, objectOpen, objectClose, arrayPrefix, arrayPostfix, fieldDelimiter, stringType, numberType, boolType string
|
var fieldSeparator, arrayPrefix, arrayPostfix, fieldDelimiter, stringType, numberType, boolType string
|
||||||
var int32Type, int64Type, floatType, doubleType, mapType, anyType, typePrefix string
|
var int32Type, int64Type, floatType, doubleType, mapType, anyType, typePrefix string
|
||||||
var fieldUpperCase bool
|
var fieldUpperCase bool
|
||||||
switch language {
|
switch language {
|
||||||
@@ -574,8 +585,8 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op
|
|||||||
fieldSeparator = "?: "
|
fieldSeparator = "?: "
|
||||||
arrayPrefix = ""
|
arrayPrefix = ""
|
||||||
arrayPostfix = "[]"
|
arrayPostfix = "[]"
|
||||||
objectOpen = "{\n"
|
//objectOpen = "{\n"
|
||||||
objectClose = "}"
|
//objectClose = "}"
|
||||||
fieldDelimiter = ";"
|
fieldDelimiter = ";"
|
||||||
stringType = "string"
|
stringType = "string"
|
||||||
numberType = "number"
|
numberType = "number"
|
||||||
@@ -592,8 +603,8 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op
|
|||||||
fieldSeparator = " "
|
fieldSeparator = " "
|
||||||
arrayPrefix = "[]"
|
arrayPrefix = "[]"
|
||||||
arrayPostfix = ""
|
arrayPostfix = ""
|
||||||
objectOpen = "{"
|
//objectOpen = "{"
|
||||||
objectClose = "}"
|
// objectClose = "}"
|
||||||
fieldDelimiter = ""
|
fieldDelimiter = ""
|
||||||
stringType = "string"
|
stringType = "string"
|
||||||
numberType = "int64"
|
numberType = "int64"
|
||||||
@@ -694,7 +705,14 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op
|
|||||||
case "boolean":
|
case "boolean":
|
||||||
ret += k + fieldSeparator + arrayPrefix + boolType + arrayPostfix + fieldDelimiter
|
ret += k + fieldSeparator + arrayPrefix + boolType + arrayPostfix + fieldDelimiter
|
||||||
case "object":
|
case "object":
|
||||||
ret += k + fieldSeparator + arrayPrefix + objectOpen + recurse(v.Value.Items.Value.Properties, level+1) + strings.Repeat(" ", level) + objectClose + arrayPostfix + fieldDelimiter
|
// type is a dynamic map
|
||||||
|
// if additional properties is not present, it's an any type,
|
||||||
|
// like the proto struct type
|
||||||
|
if v.Value.AdditionalProperties != nil {
|
||||||
|
ret += k + fieldSeparator + arrayPrefix + fmt.Sprintf(mapType, valueToType(v.Value.AdditionalProperties)) + arrayPostfix + fieldDelimiter
|
||||||
|
} else {
|
||||||
|
ret += k + fieldSeparator + arrayPrefix + fmt.Sprintf(mapType, anyType) + arrayPostfix + fieldDelimiter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "string":
|
case "string":
|
||||||
|
|||||||
@@ -52,5 +52,15 @@
|
|||||||
"id": "1"
|
"id": "1"
|
||||||
},
|
},
|
||||||
"response": {}
|
"response": {}
|
||||||
|
}],
|
||||||
|
"truncate": [{
|
||||||
|
"title": "Truncate table",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"table": "users"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
14
email/examples.json
Normal file
14
email/examples.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"send": [
|
||||||
|
{
|
||||||
|
"title": "Send email",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"subject": "Email verification",
|
||||||
|
"textBody": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link",
|
||||||
|
"from": "Awesome Dot Com"
|
||||||
|
},
|
||||||
|
"response": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
52
emoji/examples.json
Normal file
52
emoji/examples.json
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"find": [
|
||||||
|
{
|
||||||
|
"title": "Find emoji",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"alias": ":beer:"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"emoji": "🍺"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"flag": [
|
||||||
|
{
|
||||||
|
"title": "Get flag by country code",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"alias": "GB"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"flag": "🇬🇧"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"print": [
|
||||||
|
{
|
||||||
|
"title": "Print text including emoji",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"text": "let's grab a :beer:"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"text": "let's grab a 🍺"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"send": [
|
||||||
|
{
|
||||||
|
"title": "Send a text containing an emoji to anyone via SMS.",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"from": "Alice",
|
||||||
|
"to": "+44782669123",
|
||||||
|
"message": "let's grab a :beer:"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"text": "let's grab a 🍺"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@@ -28,8 +28,10 @@ require (
|
|||||||
github.com/kevinburke/twilio-go v0.0.0-20210327194925-1623146bcf73
|
github.com/kevinburke/twilio-go v0.0.0-20210327194925-1623146bcf73
|
||||||
github.com/lib/pq v1.9.0 // indirect
|
github.com/lib/pq v1.9.0 // indirect
|
||||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945
|
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945
|
||||||
|
github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3
|
||||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect
|
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect
|
||||||
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e
|
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e
|
||||||
|
github.com/micro/micro-go v0.0.0-20210909130028-36284fcb5def
|
||||||
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0
|
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0
|
||||||
github.com/miekg/dns v1.1.31 // indirect
|
github.com/miekg/dns v1.1.31 // indirect
|
||||||
github.com/oschwald/geoip2-golang v1.5.0
|
github.com/oschwald/geoip2-golang v1.5.0
|
||||||
|
|||||||
6
go.sum
6
go.sum
@@ -213,6 +213,7 @@ github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv
|
|||||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
|
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
@@ -340,6 +341,9 @@ github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8
|
|||||||
github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVLEIG/i5J9cyixzQ=
|
github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVLEIG/i5J9cyixzQ=
|
||||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 h1:jcOqgh+pYNSaPoPOgDaaU5t9j45JzHG3wOBLXUMBfQ0=
|
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945 h1:jcOqgh+pYNSaPoPOgDaaU5t9j45JzHG3wOBLXUMBfQ0=
|
||||||
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945/go.mod h1:wQOw7PY6509VQbepPrclbyXfbQ5lpOtIoHdBKbB+OGc=
|
github.com/m3o/goduckgo v0.0.0-20210630141545-c760fe67b945/go.mod h1:wQOw7PY6509VQbepPrclbyXfbQ5lpOtIoHdBKbB+OGc=
|
||||||
|
github.com/m3o/m3o-go v0.0.0-20210819131318-0fe1baa5762a h1:u1PQADkmPOkQ2Ul91g9ow24YZlIW5dbFUr5Uf/SxvoQ=
|
||||||
|
github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3 h1:RVt7rqWl4al36BH9OY9k7IXnnooOP0Feanu1bed6X2s=
|
||||||
|
github.com/m3o/m3o-go/client v0.0.0-20210421144725-8bfd7992ada3/go.mod h1:vmeaYrKYpgVNhny/l7iH8mXS88S7ijUiYni3gZUrCq0=
|
||||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a h1:rnrxZue85aKdMU4nJ50GgKA31lCaVbft+7Xl8OXj55U=
|
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a h1:rnrxZue85aKdMU4nJ50GgKA31lCaVbft+7Xl8OXj55U=
|
||||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a/go.mod h1:hJJYoBMTZIONmUEpX3+9v2057zuRM0n3n77U4Ob4wE4=
|
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a/go.mod h1:hJJYoBMTZIONmUEpX3+9v2057zuRM0n3n77U4Ob4wE4=
|
||||||
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e h1:cj+w63ez19o7y7vunA8Q3rUIWwKEOUx7foqjnr4qbtI=
|
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e h1:cj+w63ez19o7y7vunA8Q3rUIWwKEOUx7foqjnr4qbtI=
|
||||||
@@ -366,6 +370,8 @@ github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KK
|
|||||||
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||||
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
|
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/micro/micro-go v0.0.0-20210909130028-36284fcb5def h1:mvyIKMKL1zXfPLE8THrvK7BqP2K0TdO5WymaqCRgDn4=
|
||||||
|
github.com/micro/micro-go v0.0.0-20210909130028-36284fcb5def/go.mod h1:Jlbljy5hUymPXkB5M1hCPxtY6l64dkQRA/EvazcQoQM=
|
||||||
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0 h1:TNsE0OkoYpb3DTDBsTm7vUvKoyp8zkUuUprxhIpMjoM=
|
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0 h1:TNsE0OkoYpb3DTDBsTm7vUvKoyp8zkUuUprxhIpMjoM=
|
||||||
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0/go.mod h1:bkhxUsib0oX41JNr5qlxTt2LYzzGXJWet4d/Vwvb6Wg=
|
github.com/micro/micro/v3 v3.4.1-0.20210910132548-f8bfb12823c0/go.mod h1:bkhxUsib0oX41JNr5qlxTt2LYzzGXJWet4d/Vwvb6Wg=
|
||||||
github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
|
|||||||
@@ -1,45 +1,88 @@
|
|||||||
{
|
{
|
||||||
"resize": [{
|
"resize": [
|
||||||
"title": "Base64 to hosted image",
|
{
|
||||||
"description": "Resize an input base64 encoded image and store the resulting resized image on our CDN.",
|
"title": "Base64 to hosted image",
|
||||||
"run_check": true,
|
"description": "Resize an input base64 encoded image and store the resulting resized image on our CDN.",
|
||||||
"request": {
|
"run_check": true,
|
||||||
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
"request": {
|
||||||
"outputURL": true,
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
"name": "cat.png",
|
"outputURL": true,
|
||||||
"width": 100,
|
"name": "cat.png",
|
||||||
"height": 100
|
"width": 100,
|
||||||
},
|
"height": 100
|
||||||
"response": {
|
},
|
||||||
"url": "cdn.images.m3o.com/your-account-id/cat.png"
|
"response": {
|
||||||
|
"url": "cdn.images.m3o.com/your-account-id/cat.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Base64 to base64 image",
|
||||||
|
"description": "Resize a base64 encoded image on the fly without storing it anywhere",
|
||||||
|
"run_check": true,
|
||||||
|
"request": {
|
||||||
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
|
"width": 100,
|
||||||
|
"height": 100
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Base64 to base64 image with cropping",
|
||||||
|
"description": "Resize a base64 encoded image on the fly without storing it anywhere",
|
||||||
|
"run_check": true,
|
||||||
|
"request": {
|
||||||
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
||||||
|
"width": 100,
|
||||||
|
"height": 100,
|
||||||
|
"cropOptions": {
|
||||||
|
"width": 50,
|
||||||
|
"height": 50
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
"title": "Base64 to base64 image",
|
"response": {
|
||||||
"description": "Resize a base64 encoded image on the fly without storing it anywhere",
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg=="
|
||||||
"run_check": true,
|
}
|
||||||
"request": {
|
}
|
||||||
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
],
|
||||||
"width": 100,
|
"convert": [
|
||||||
"height": 100
|
{
|
||||||
},
|
"title": "Convert a png image to a jpeg, taken from a URL and saved to a URL on Micro's CDN",
|
||||||
"response": {
|
"run_check": false,
|
||||||
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
|
"request": {
|
||||||
}
|
"url": "somewebsite.com/cat.png",
|
||||||
},{
|
"name": "cat.jpeg",
|
||||||
"title": "Base64 to base64 image with cropping",
|
"outputURL": true
|
||||||
"description": "Resize a base64 encoded image on the fly without storing it anywhere",
|
},
|
||||||
"run_check": true,
|
"response": {
|
||||||
"request": {
|
"url": "cdn.images.m3o.com/your-account-id/cat.jpeg"
|
||||||
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
|
}
|
||||||
"width": 100,
|
}
|
||||||
"height": 100,
|
],
|
||||||
"cropOptions":{
|
"upload": [
|
||||||
"width": 50,
|
{
|
||||||
"height": 50
|
"title": "Upload a base64 image to Micro's CDN",
|
||||||
}
|
"run_check": false,
|
||||||
},
|
"request": {
|
||||||
"response": {
|
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg==",
|
||||||
"base64": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAx0lEQVR4nOzaMaoDMQyE4ZHj+x82vVdhwQoTkzKQEcwP5r0ihT7sbjUTeAJ4HCegXQJYfOYefOyjDuBiz3yjwJBoCIl6QZOeUjTC1Ix1IxEJXF9+0KWsf2bD4bn37OO/c/wuQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9Sa/NG94Tf3j4WBdaxudMEkn4IM2rZBA0wBrvo7aOcpj2emXvLeVt0IGm0GVXUj91mvAAAA//+V2CZl+4AKXwAAAABJRU5ErkJggg=="
|
"name": "cat.jpeg",
|
||||||
}
|
"outputURL": true
|
||||||
}]
|
},
|
||||||
|
"response": {
|
||||||
|
"url": "cdn.images.m3o.com/your-account-id/cat.jpeg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Upload an image from a URL to Micro's CDN",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"url": "somewebsite.com/cat.png",
|
||||||
|
"name": "cat.jpeg"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"url": "cdn.images.m3o.com/your-account-id/cat.jpeg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
48
postcode/examples.json
Normal file
48
postcode/examples.json
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"lookup": [
|
||||||
|
{
|
||||||
|
"title": "Lookup postcode",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"postcode": "SW1A 2AA"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"postcode": "SW1A 2AA",
|
||||||
|
"country": "England",
|
||||||
|
"region": "London",
|
||||||
|
"district": "Westminster",
|
||||||
|
"ward": "St James's",
|
||||||
|
"latitude": 51.50354,
|
||||||
|
"longitude": -0.127695
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"random": [
|
||||||
|
{
|
||||||
|
"title": "Return a random postcode and its information",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {},
|
||||||
|
"response": {
|
||||||
|
"postcode": "OX26 2HA",
|
||||||
|
"country": "England",
|
||||||
|
"region": "South East",
|
||||||
|
"district": "Cherwell",
|
||||||
|
"ward": "Bicester West",
|
||||||
|
"latitude": 51.907678,
|
||||||
|
"longitude": -1.163954
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"validate": [
|
||||||
|
{
|
||||||
|
"title": "Return a random postcode and its information",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"postcode": "SW1A 2AA"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"valid": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
14
sms/examples.json
Normal file
14
sms/examples.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"send": [{
|
||||||
|
"title": "Send SMS",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"from": "Alice",
|
||||||
|
"message": "Hi there!",
|
||||||
|
"to": "+447681129"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"status": "ok"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
16
thumbnail/examples.json
Normal file
16
thumbnail/examples.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"screenshot": [
|
||||||
|
{
|
||||||
|
"title": "Take screenshot of a URL",
|
||||||
|
"run_check": true,
|
||||||
|
"request": {
|
||||||
|
"height": 600,
|
||||||
|
"url": "https://m3o.com",
|
||||||
|
"width": 600
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"imageURL": "https://cdn.m3ocontent.com/micro/images/micro/505237c9-f254-4014-9a4c-1ec7eac0882a/ef9749ef-40b0-4ba1-a413-6136a8b0924c.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
36
time/examples.json
Normal file
36
time/examples.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"now": [
|
||||||
|
{
|
||||||
|
"title": "Returns current time, optionally with location",
|
||||||
|
"run_check": true,
|
||||||
|
"request": {},
|
||||||
|
"response": {
|
||||||
|
"localtime": "14:35:44",
|
||||||
|
"timestamp": "2021-09-13T14:35:44.144293723Z",
|
||||||
|
"location": "Prime Meridian",
|
||||||
|
"timezone": "UTC",
|
||||||
|
"unix": "1631543744"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"zone": [
|
||||||
|
{
|
||||||
|
"title": "Get the timezone info for a specific location",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"location": "London"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"location": "London",
|
||||||
|
"region": "City of London, Greater London",
|
||||||
|
"country": "United Kingdom",
|
||||||
|
"latitude": 51.52,
|
||||||
|
"longitude": -0.11,
|
||||||
|
"timezone": "Europe/London",
|
||||||
|
"abbreviation": "BST",
|
||||||
|
"localtime": "2021-09-13 15:37",
|
||||||
|
"dst": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,75 +1,118 @@
|
|||||||
{
|
{
|
||||||
"create": [{
|
"create": [
|
||||||
"title": "Create an account",
|
{
|
||||||
"run_check": true,
|
"title": "Create an account",
|
||||||
"request": {
|
"run_check": true,
|
||||||
"id": "usrid-1",
|
"request": {
|
||||||
"username": "usrname-1",
|
"id": "usrid-1",
|
||||||
"email": "joe@example.com",
|
"username": "usrname-1",
|
||||||
"password": "mySecretPass123"
|
"email": "joe@example.com",
|
||||||
},
|
"password": "mySecretPass123"
|
||||||
"response": {
|
},
|
||||||
|
"response": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"read": [
|
||||||
|
{
|
||||||
|
"title": "Read an account by id",
|
||||||
|
"run_check": true,
|
||||||
|
"request": {
|
||||||
|
"id": "usrid-1"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"account": {
|
||||||
|
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||||
|
"username": "usrname-1",
|
||||||
|
"email": "joe@example.com",
|
||||||
|
"created": "1623677579",
|
||||||
|
"updated": "1623677579"
|
||||||
}
|
}
|
||||||
}],
|
}
|
||||||
"read": [{
|
},
|
||||||
"title": "Read an account by id",
|
{
|
||||||
"run_check": true,
|
"title": "Read account by username or email",
|
||||||
"request": {
|
"run_check": true,
|
||||||
"id": "usrid-1"
|
"request": {
|
||||||
},
|
"username": "usrname-1"
|
||||||
"response": {
|
},
|
||||||
"account": {
|
"response": {
|
||||||
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
"account": {
|
||||||
"username": "usrname-1",
|
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||||
"email": "joe@example.com",
|
"username": "usrname-1",
|
||||||
"created": "1623677579",
|
"email": "joe@example.com",
|
||||||
"updated": "1623677579"
|
"created": "1623677579",
|
||||||
}
|
"updated": "1623677579"
|
||||||
}
|
}
|
||||||
},{
|
}
|
||||||
"title": "Read account by username or email",
|
},
|
||||||
"run_check": true,
|
{
|
||||||
"request": {
|
"title": "Read account by email",
|
||||||
"username": "usrname-1"
|
"run_check": true,
|
||||||
},
|
"request": {
|
||||||
"response": {
|
"email": "joe@example.com"
|
||||||
"account": {
|
},
|
||||||
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
"response": {
|
||||||
"username": "usrname-1",
|
"account": {
|
||||||
"email": "joe@example.com",
|
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
||||||
"created": "1623677579",
|
"username": "usrname-1",
|
||||||
"updated": "1623677579"
|
"email": "joe@example.com",
|
||||||
}
|
"created": "1623677579",
|
||||||
|
"updated": "1623677579"
|
||||||
}
|
}
|
||||||
},{
|
}
|
||||||
|
}
|
||||||
"title": "Read account by email",
|
],
|
||||||
"run_check": true,
|
"sendVerificationEmail": [
|
||||||
"request": {
|
{
|
||||||
"email": "joe@example.com"
|
"title": "Send verification email",
|
||||||
},
|
"run_check": true,
|
||||||
"response": {
|
"request": {
|
||||||
"account": {
|
"email": "joe@example.com",
|
||||||
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f",
|
"subject": "Email verification",
|
||||||
"username": "usrname-1",
|
"redirectUrl": "https://m3o.com",
|
||||||
"email": "joe@example.com",
|
"failureRedirectUrl": "https://m3o.com/verification-failed",
|
||||||
"created": "1623677579",
|
"textContent": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link",
|
||||||
"updated": "1623677579"
|
"fromName": "Awesome Dot Com"
|
||||||
}
|
},
|
||||||
|
"response": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"delete": [
|
||||||
|
{
|
||||||
|
"title": "Delete user account",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"id": "fdf34f34f34-f34f34-f43f43f34-f4f34f"
|
||||||
|
},
|
||||||
|
"response": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"login": [
|
||||||
|
{
|
||||||
|
"title": "Log a user in",
|
||||||
|
"run_check": false,
|
||||||
|
"request": {
|
||||||
|
"email": "joe@example.com",
|
||||||
|
"password": "mySecretPass123"
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"session": {
|
||||||
|
"id": "sds34s34s34-s34s34-s43s43s34-s4s34s",
|
||||||
|
"created": "1623677579",
|
||||||
|
"expires": "1623699579",
|
||||||
|
"userId": "fdf34f34f34-f34f34-f43f43f34-f4f34f"
|
||||||
}
|
}
|
||||||
}],
|
}
|
||||||
"sendVerificationEmail": [{
|
}
|
||||||
"title": "Send verification email",
|
],
|
||||||
"run_check": true,
|
"logout": [
|
||||||
"request": {
|
{
|
||||||
"email": "joe@example.com",
|
"title": "Log a user out",
|
||||||
"subject": "Email verification",
|
"run_check": false,
|
||||||
"redirectUrl": "https://m3o.com",
|
"request": {
|
||||||
"failureRedirectUrl": "https://m3o.com/verification-failed",
|
"sessionId": "sds34s34s34-s34s34-s43s43s34-s4s34s"
|
||||||
"textContent": "Hi there,\n\nPlease verify your email by clicking this link: $micro_verification_link",
|
},
|
||||||
"fromName": "Awesome Dot Com"
|
"response": {}
|
||||||
},
|
}
|
||||||
"response": {
|
]
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user