-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathswagger.yaml
292 lines (286 loc) · 9.03 KB
/
swagger.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
openapi: 3.0.0
info:
description: Sample API for Universal QR Codes
version: 1.0.1
title: Universal QR Code API
tags:
- name: endpoint
description: |
## What is this:
URL to get the hostname from a QR code label - potentially hosted on a different server.
This endpoint should also provide the vendor for the label,
in order to assist in developers matching their API tokens to the correct endpoints.
## Usage:
View a JSON schema of this inside the /wellknown/cannabis-api.schema.json
The 'vendor' tag allows a developer to easily match their stored API keys to the endpoint.
## Additional Endpoints:
If you would like additional endpoints to be stored in the cannabis-api.json file, you can specify them with fieldname-endpoint. For example 'distributor-endpoint' or 'pos-endpoint'. You should *always* have an endpoint entry, however.
- name: product
description: Information about product details like product name, description, doses, etc
- name: batch
description: Information about batch details like testing and THC content
- name: case
description: |
Case matching input id - a case comes from a manufacturer and is a collection of items that are all the same.
It cannot contain different item types.
- name: each
description: Information and updating a serialized package - single unit of a product / batch
- name: regulator
description: Query for details about regulator tags
- name: manifest
description: |
Get details from an order (probably from a distributor), describing child package to QR code url mappings
The contents field contains an array of QR codes that represent all scanned cases or items,
allowing a lookup on a per-vendor basis of the data about those cases or items.
In order to use the cases in your system, just perform a lookup on the case information endpoint and get the each IDs -
then use those to identify the scanned out QR codes.
The regulatorEvent entry represents the transfer ID (if applicable).
Using the manifest endpoint, a retailer can scan a single barcode on a box and then use subsequent
API calls using the standard (to multiple vendors) to get information about the associated regulator tags and product information.
security:
- Bearer Token:
- write
servers:
- url: https://qr.example.com/v1/uapi
description: Server for your universal API
paths:
/.well-known/cannabis-api.json:
get:
tags:
- endpoint
servers:
- url: https://shortqrurl.com/
responses:
200:
description: Successfully retrieved file
content:
application/json:
schema:
type: object
required:
- endpoint
- vendor
properties:
endpoint:
type: string
example: qr.example.com/uapi/v1/
path-components:
type: string
example: qr.example.com/i/:id
vendor:
type: string
enum: ["nabis", "lucidgreen", "chroma"]
example: nabis
"*-endpoint":
type: string
example: qr-poc.example.com/uapi/v1/
/batch/{id}:
get:
tags:
- batch
parameters:
- in: path
name: id
description: id of record to look up
required: true
schema:
type: string
responses:
200:
description: Get information about the batch from either a Collection id or an Each id
content:
application/json:
schema:
$ref: ./schemas/Batch.yaml
/product/{id}:
get:
tags:
- product
parameters:
- in: path
name: id
description: id of record to look up
required: true
schema:
type: string
responses:
200:
description: sku matching input identifier
content:
application/json:
schema:
$ref: ./schemas/Product.yaml
/case/{id}:
get:
tags:
- case
parameters:
- $ref: "#/components/parameters/pathId"
- $ref: "#/components/parameters/excludeFields"
responses:
200:
description: Case matching input Id
content:
application/json:
schema:
$ref: ./schemas/Case.yaml
put:
tags:
- case
parameters:
- $ref: "#/components/parameters/pathId"
requestBody:
$ref: "#/components/requestBodies/regulatorBody"
responses:
200:
description: Success
content:
application/json:
schema:
$ref: ./schemas/Case.yaml
/each/{id}:
get:
tags:
- each
parameters:
- $ref: "#/components/parameters/pathId"
- $ref: "#/components/parameters/excludeFields"
responses:
200:
description: Each matching input id
content:
application/json:
schema:
$ref: ./schemas/Each.yaml
put:
tags:
- each
parameters:
- $ref: "#/components/parameters/pathId"
requestBody:
$ref: "#/components/requestBodies/regulatorBody"
responses:
200:
description: Each matching input id
content:
application/json:
schema:
$ref: ./schemas/Each.yaml
/regulator/{id}:
get:
tags:
- regulator
parameters:
- $ref: "#/components/parameters/pathId"
responses:
200:
$ref: "#/components/responses/eachesAndCasesResponse"
put:
tags:
- regulator
parameters:
- $ref: "#/components/parameters/pathId"
requestBody:
$ref: "#/components/requestBodies/regulatorMultiputBody"
responses:
200:
description: Returns the regulator event that was attached to these items, fails if the items are not all from the same parent
content:
application/json:
schema:
$ref: ./schemas/Regulator.yaml
404:
description: Returned if not all ids were able to be attached, this indicates an error in the tagging Flower"
content:
application/json:
schema:
type: object
properties:
failures:
$ref: ./schemas/IdArray.yaml
/manifest/{id}:
get:
tags:
- manifest
parameters:
- $ref: "#/components/parameters/pathId"
responses:
200:
description: Success
content:
application/json:
schema:
$ref: ./schemas/Manifest.yaml
example:
regulatorEvent:
id: "0003166342"
kind: manifest
contents:
- "qr.example.com/i/1234"
- "qr-test.example.com/i/abcd"
components:
securitySchemes:
Bearer Token:
type: http
scheme: bearer
bearerFormat: JWT
description: |
Any users may generate a bearer API token from their account page on a respective labeling site.
Tokens are only needed for write operations - all read operations can happen without authentication.
schemas:
$ref: schemas/_index.yaml
parameters:
pathId:
in: path
name: id
description: id to look up
required: true
schema:
type: string
excludeFields:
in: query
name: excludedFields
description: comma separated list of fields to exclude in the request body
required: false
schema:
type: array
example: "product,batch"
items:
type: string
requestBodies:
regulatorBody:
description: Body for a put / post with regulator information
content:
application/json:
schema:
oneOf:
- $ref: ./schemas/Regulator.yaml
regulatorMultiputBody:
description: Body for a request to put a regulator id on multiple items
content:
application/json:
schema:
type: object
properties:
ids:
$ref: ./schemas/IdArray.yaml
responses:
eachesAndCasesResponse:
description: Array of eaches, cases, and regualator events associated with a regulatorId
content:
application/json:
schema:
type: object
properties:
eaches:
type: array
items:
$ref: ./schemas/IdArray.yaml
cases:
type: array
items:
$ref: ./schemas/IdArray.yaml
regulatorEvents:
type: array
items:
$ref: ./schemas/Regulator.yaml