swagger OK resopnse bodies

master
breel 2020-08-09 22:23:39 -06:00
parent f11261f0da
commit 4aea3dab40
9 changed files with 288 additions and 80 deletions

View File

@ -8,19 +8,16 @@ function main() {
go test ./...
fi
GOOS=linux GOARCH=arm GOARM=5 gobuild $exec
for authed in dndex; do # dndex-auth; do
scp ./public/swagger/* zach@tickle.lan:./$authed/files/swagger/
scp $exec zach@tickle.lan:./$authed/dndex.new
ssh zach@tickle.lan bash -c "true; while [ -e ./$authed/dndex.new ]; do printf '.'; sleep 3; done; echo"
done &
wait
scp -r ./public/swagger/* zach@tickle.lan:./dndex1/files/swagger/
scp $exec zach@tickle.lan:./dndex1/dndex.new
ssh zach@tickle.lan bash -c "true; while [ -e ./dndex1/dndex.new ]; do printf '.'; sleep 3; done; echo"
if [ -n "$BIG" ]; then
GOOS=linux gobuild $exec
echo scp $exec bel@remote.blapointe.com:/home/bel/services/bin/dndex.new
echo ssh bel@remote.blapointe.com bash -c 'true; md5sum ./services/bin/dndex*; while [ -e ./services/bin/dndex.new ]; do printf "."; sleep 3; done; md5sum ./services/bin/dndex*'
rm $exec
if [ -n "$BIG" ]; then
big
fi
rm $exec
}
function gobuild() {

31
init.sh
View File

@ -1,31 +0,0 @@
#! /bin/bash
port=57017
if false && ! curl -sS localhost:$port > /dev/null; then
prefix=/tmp/whodunit.db
mkdir -p $prefix/data
mongod \
--dbpath $prefix/data \
--logpath $prefix/log \
--pidfilepath $prefix/pid \
--port $port \
--fork
fi
mshell() {
mongo \
--quiet \
--port $port \
--eval "$*"
}
remove() {
mshell \
'db.getSiblingDB("db")["col"].remove({})'
}
export DBURI=${DB_URI:-"mongodb://localhost:$port"}
export DRIVERTYPE=boltdb
export DBURI=$(mktemp)

View File

@ -0,0 +1,66 @@
paths:
summary: "Interact with one entity within a namespace"
delete:
description: "Delete an existing entity"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
responses:
200:
$ref: "#/components/schemas/responseOK"
get:
description: "Get an existing entity"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
responses:
200:
$ref: "#/components/schemas/responseOneResolved"
put:
description: "Replace an existing entity"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
requestBody:
$ref: "#/components/schemas/requestOne"
responses:
200:
$ref: "#/components/schemas/responseOne"
patch:
description: "Update an existing entity"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
requestBody:
$ref: "#/components/schemas/requestOne"
responses:
200:
$ref: "#/components/schemas/responseOne"
components:
parameters:
token:
$ref: "../swagger.yaml#/components/parameters/token"
id:
$ref: "../swagger.yaml#/components/parameters/id"
schemas:
requestOne:
$ref: "../swagger.yaml#/components/schemas/requestOne"
responseOne:
$ref: "../swagger.yaml#/components/schemas/responseOne"
responseOneResolved:
$ref: "../swagger.yaml#/components/schemas/responseOneResolved"
responseOK:
$ref: "../swagger.yaml#/components/schemas/responseOK"

View File

@ -0,0 +1,71 @@
paths:
summary: "Interact with one field of one entity within a namespace"
delete:
description: "Delete an existing entity's field's value"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/path"
responses:
200:
$ref: "#/components/schemas/responseOne"
get:
description: "Get an existing entity's field's value"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/path"
responses:
200:
$ref: "#/components/schemas/responseOne"
put:
description: "Replace an existing entity's field's value"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/path"
requestBody:
$ref: "#/components/schemas/requestOne"
responses:
200:
$ref: "#/components/schemas/responseOne"
patch:
description: "Update an existing entity's field's value"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/path"
requestBody:
$ref: "#/components/schemas/requestOne"
responses:
200:
$ref: "#/components/schemas/responseOne"
components:
parameters:
token:
$ref: "../swagger.yaml#/components/parameters/token"
id:
$ref: "../swagger.yaml#/components/parameters/id"
path:
$ref: "../swagger.yaml#/components/parameters/path"
schemas:
responseOne:
$ref: "../swagger.yaml#/components/schemas/responseOne"
requestOne:
$ref: "../swagger.yaml#/components/schemas/requestOne"
objectOne:
$ref: "../swagger.yaml#/components/schemas/objectOne"
responseOK:
$ref: "../swagger.yaml#/components/schemas/responseOK"

View File

@ -0,0 +1,44 @@
paths:
summary: "Interact with all entities within a namespace"
get:
description: "Get names and IDs of all entities"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
responses:
200:
content:
applicaiton/json:
schema:
type: array
items:
type: object
properties:
Name: string
ID: string
example:
Name: John Smith
ID: abc-123
post:
description: "Create a new entity"
tags:
- entities
parameters:
- $ref: "#/components/parameters/token"
requestBody:
$ref: "#/components/schemas/requestOne"
responses:
200:
$ref: "#/components/schemas/responseOne"
components:
parameters:
token:
$ref: "../swagger.yaml#/components/parameters/token"
schemas:
requestOne:
$ref: "../swagger.yaml#/components/schemas/requestOne"
responseOne:
$ref: "../swagger.yaml#/components/schemas/responseOne"

View File

@ -12,8 +12,7 @@ info:
version: 0.1.0
servers:
- url: http://api.dndex.lan:8080/
- url: http://authapi.dndex.lan:8080/
- url: http://api1.dndex.lan:8080/
paths:
/version:
@ -24,11 +23,22 @@ paths:
$ref: "./users/register.yaml#/paths"
/users/login:
$ref: "./users/login.yaml#/paths"
#/entities:
# $ref: "./entities.yaml#/paths"
/entities:
$ref: "./entities/index.yaml#/paths"
/entities/{id}:
$ref: "./entities/id.yaml#/paths"
/entities/{id}/{path}:
$ref: "./entities/idsub.yaml#/paths"
components:
parameters:
id:
name: id
in: path
required: true
schema:
type: string
path:
name: path
in: path
@ -44,9 +54,23 @@ components:
type: string
schemas:
responseOneResolved:
content:
application/json:
schema:
$ref: "#/components/schemas/objectOneResolved"
responseOne:
content:
application/json:
schema:
$ref: "#/components/schemas/objectOne"
responseOK:
content:
application/json:
schema:
type: object
properties:
ok:
type: boolean
@ -59,40 +83,53 @@ components:
type: string
example: http://imgur.com/big-tiddy-goth-gf.jpg
objectID:
title: "one ID"
type: string
example: "abc-123-def-456"
requestOne:
content:
application/json:
schema:
$ref: "#/components/schemas/objectOne"
objectOne:
title: "one entity"
type: object
properties:
_id:
$ref: "/components/schemas/objectID"
name:
type: string
example: "Jeff Snow"
type:
type: string
example: "doggo"
title:
type: string
example: "Meme Lord"
text:
type: string
example: "Lorem ipsum"
modified:
type: int
example: 8675309
attachments:
oneID: { type: string, example: "abc-123-def-456" }
oneName: { type: string, example: "Jeff Snow" }
oneType: { type: string, example: "Doggo" }
oneTitle: { type: string, example: "Meme Lord" }
oneText: { type: string, example: "Lorem ipsum" }
oneModified: { type: int, example: 1234567890 }
oneAttachments:
type: object
additionalProperties:
type: object
properties:
location:
type: string
example: "/files/my/file.txt"
example:
"abc-123-def-456":
location: "/__files__/my/file.txt"
objectOneResolved:
type: object
properties:
_id: { $ref: "#/components/schemas/oneID" }
name: { $ref: "#/components/schemas/oneName" }
type: { $ref: "#/components/schemas/oneType" }
title: { $ref: "#/components/schemas/oneTitle" }
text: { $ref: "#/components/schemas/oneText" }
modified: { $ref: "#/components/schemas/oneModified" }
attachments: { $ref: "#/components/schemas/oneAttachments" }
connections:
type: object
additionalProperties: { $ref: "#/components/schemas/objectOne" }
objectOne:
type: object
properties:
_id: { $ref: "#/components/schemas/oneID" }
name: { $ref: "#/components/schemas/oneName" }
type: { $ref: "#/components/schemas/oneType" }
title: { $ref: "#/components/schemas/oneTitle" }
text: { $ref: "#/components/schemas/oneText" }
modified: { $ref: "#/components/schemas/oneModified" }
attachments: { $ref: "#/components/schemas/oneAttachments" }
connections:
type: object
additionalProperties:
@ -100,7 +137,9 @@ components:
properties:
relationship:
type: string
example: "friendly"
example:
"abc-123-def-456":
relationship: "friendly"
securitySchemes:
token:

View File

@ -13,3 +13,16 @@ paths:
DnDex-User:
type: string
example: "namespace"
responses:
200:
content:
application/json:
schema:
type: object
properties:
token:
type: string
example: abc-123
salt:
type: string
example: def-456

View File

@ -15,3 +15,11 @@ paths:
DnDex-Auth:
type: string
example: "password"
responses:
200:
$ref: "#/components/schemas/responseOK"
components:
schemas:
responseOK:
$ref: "../swagger.yaml#/components/schemas/responseOK"

View File

@ -13,3 +13,4 @@ paths:
version:
type: string
example: "02c5d795cf631a33528234a9cf52907c6cd34834"