Skip to content

Commit dae21e5

Browse files
committed
update schema details
1 parent 407457c commit dae21e5

File tree

12 files changed

+226
-28
lines changed

12 files changed

+226
-28
lines changed

bin/build-openapi.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,27 @@
2828
, APP_ROOT
2929
, $s_name
3030
);
31+
echo "Output: $output_file\n";
3132

3233
$output_data = $s_data;
3334
foreach ($output_data['properties'] as $pk => $pv) {
3435
if ('ulid' == $pv['type']) {
3536
$output_data['properties'][$pk]['type'] = 'string';
3637
}
38+
if (isset($pv['$ref'])) {
39+
// var_dump($pv);
40+
$c = basename($pv['$ref']);
41+
// var_dump($c);
42+
$obj = $yaml_data['components']['schemas'][$c];
43+
$output_data['properties'][$pk] = $obj;
44+
// $path = trim($pv['$ref'], '#/');
45+
// $path_list = explode('/', $path);
46+
// var_dump($path_list);
47+
// echo "Resolve\n";
48+
// exit;
49+
}
3750
}
51+
3852
$output_data['$schema'] = 'http://json-schema.org/schema#';
3953
_ksort_r($output_data);
4054

@@ -45,8 +59,11 @@
4559

4660
$yaml_text = yaml_emit($yaml_data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
4761

48-
echo "#\n# Generated File\n#\n\n";
49-
echo $yaml_text;
62+
$data = "#\n# Generated File\n#\n\n$yaml_text";
63+
$file = sprintf('%s/webroot/openapi.yaml', APP_ROOT);
64+
65+
file_put_contents($file, $data);
66+
5067

5168
/**
5269
* Helper on YAML Processor

openapi/components/schema.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,26 @@ Inventory:
134134
description: Freeform name of the Inventory, if desired
135135
type: string
136136
section:
137-
$ref: '#/components/schemas/Section'
137+
# $ref: '#/components/schemas/Section'
138+
type: object
139+
properties:
140+
id:
141+
description: "The Section Identifier"
142+
type: string
138143
variety:
139-
$ref: '#/components/schemas/Variety'
144+
# $ref: '#/components/schemas/Variety'
145+
type: object
146+
properties:
147+
id:
148+
description: "The Variety Identifier"
149+
type: string
140150
product:
141-
$ref: '#/components/schemas/Product'
151+
# $ref: '#/components/schemas/Product'
152+
type: object
153+
properties:
154+
id:
155+
description: "The Product Identifier"
156+
type: string
142157
qty:
143158
description: Current Quantity of the Product on Hand
144159
type: number
@@ -214,8 +229,8 @@ B2B_File:
214229
description: "ID"
215230
type: string
216231
data:
217-
description: "The File Contents"
218-
type: binary
232+
description: "The File Contents, Base64-URL Encoded"
233+
type: string
219234
link:
220235
description: "A Link to the File Contents"
221236
type: string

openapi/components/schema/Company.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ properties:
1919
code:
2020
description: A Unique Identifier Code; typically a Government issued ID
2121
type: string
22-
type:
23-
$ref: '#/components/schemas/Company_Type'
22+
# type:
23+
# $ref: '#/components/schemas/Company_Type'

openapi/components/schema/Lab_Result.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,26 @@ type: object
2323
properties:
2424
id:
2525
type: string
26-
company:
27-
description: The Company Object of the Laboratory Submitting Results
28-
type: object
29-
$ref: '#/components/schemas/Company'
26+
# company:
27+
# description: The Company Object of the Laboratory Submitting Results
28+
# type: object
29+
# # $ref: '#/components/schemas/Company'
3030
license:
31+
# $ref: '#/components/schemas/License'
3132
description: The License Object of the Laboratory Submitting Results
3233
type: object
33-
$ref: '#/components/schemas/License'
34+
properties:
35+
id:
36+
description: "The License Identifier"
37+
type: string
3438
lab_sample:
3539
description: The Lab Sample this Result is for
3640
type: object
37-
$ref: '#/components/schemas/Lab_Sample'
41+
# $ref: '#/components/schemas/Lab_Sample'
42+
properties:
43+
id:
44+
description: "The Lab Sample Identifier"
45+
type: string
3846
contact:
3947
description: The Contact Object of the Laboratory Technician Submitting Results
4048
type: object

openapi/components/schema/Lab_Sample.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
description: "A Special type of Inventory Lot that becomes a Laboratory Sample"
1010
type: object
11-
required: [ "id", "license" ]
11+
required: [ "id", "license", "origin" ]
1212
properties:
1313
id:
1414
description: ID of this specific Lab Sample
@@ -29,9 +29,33 @@ properties:
2929
description: DateTime when deleted -- null indicates NOT deleted
3030
type: string
3131
format: dateTime
32-
license_origin:
32+
license:
3333
description: The License of the Owner of the Sample
34-
$ref: '#/components/schemas/License'
34+
# $ref: '#/components/schemas/License'
35+
type: object
36+
properties:
37+
id:
38+
description: "The License Identifier"
39+
type: string
40+
origin:
41+
description: Origin Details of the Lab Sample
42+
# $ref: '#/components/schemas/License'
43+
type: object
44+
properties:
45+
inventory:
46+
type: object
47+
properties:
48+
id:
49+
description: "The Origin/Source Inventory Identifier"
50+
type: string
51+
license:
52+
description: "The Origin/Source License Identifier"
53+
type: object
54+
properties:
55+
id:
56+
description: "The Origin/Source Inventory Identifier"
57+
type: string
58+
3559

3660
# laboratory:
3761
# description: Laboratory Details, object with id and name properties

openapi/components/schema/License.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ properties:
2020
description: A Unique Identifier Code; typically a Government issued ID
2121
type: string
2222
type:
23-
$ref: '#/components/schemas/License_Type'
23+
# $ref: '#/components/schemas/License_Type'
24+
description: "Identifier of the License Type"
25+
type: object
26+
properties:
27+
id:
28+
description: "The License Type Identifier"
29+
type: string
2430
company:
25-
$ref: '#/components/schemas/Company'
2631
description: Company Object which owns this license
32+
type: object
33+
properties:
34+
id:
35+
description: "The Company Identifier"
36+
type: string
37+
38+
# $ref: '#/components/schemas/Company'

openapi/components/schema/Product.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ properties:
1515
name:
1616
description: Free-form name of the Product
1717
type: string
18-
type:
19-
$ref: '#/components/schemas/Product_Type'
18+
# type:
19+
# $ref: '#/components/schemas/Product_Type'
2020
package:
2121
type: object
2222
properties:

openapi/paths/_.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
/b2b/outgoing/{id}/item:
219219
$ref: './b2b/single-item-create.yaml'
220220

221-
/b2b/outgoing/{id}/item/{iid}:
221+
/b2b/outgoing/{id}/item/{item_id}:
222222
$ref: './b2b/single-item-single.yaml'
223223

224224
/b2b/outgoing/{id}/file:
@@ -236,11 +236,21 @@
236236
/b2b/incoming/{id}:
237237
$ref: './b2b/single.yaml'
238238

239-
/b2b/outgoing/{id}/item:
240-
$ref: './b2b/single-item-create.yaml'
241-
242-
/b2b/outgoing/{id}/item/{iid}:
243-
$ref: './b2b/single-item-single.yaml'
239+
/b2b/incoming/{id}/item:
240+
get:
241+
$ref: './b2b/incoming/item/search.yaml'
242+
post:
243+
$ref: './b2b/incoming/item/create.yaml'
244+
245+
/b2b/incoming/{id}/item/{item_id}:
246+
get:
247+
$ref: './b2b/incoming/item/detail.yaml'
248+
patch:
249+
$ref: './b2b/incoming/item/update.yaml'
250+
post:
251+
$ref: './b2b/incoming/item/update.yaml'
252+
put:
253+
$ref: './b2b/incoming/item/update.yaml'
244254

245255
/b2b/incoming/{id}/commit:
246256
$ref: './b2b/commit.yaml'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# B2B Incoming Item Create
3+
#
4+
5+
summary: B2B Incoming Transaction Item Create
6+
tags:
7+
- B2B Transaction
8+
parameters:
9+
- name: id
10+
description: The B2B Transaction ID
11+
in: path
12+
required: true
13+
schema:
14+
type: string
15+
responses:
16+
'201':
17+
description: Success
18+
content:
19+
application/json:
20+
schema:
21+
type: array
22+
items:
23+
$ref: '#/components/schemas/B2B_Sale'
24+
'401':
25+
description: "Not Authorized"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# B2B Incoming Item Detail
3+
#
4+
5+
summary: B2B Incoming Transaction Item Detail
6+
tags:
7+
- B2B Transaction
8+
parameters:
9+
- name: id
10+
description: The B2B Transaction ID
11+
in: path
12+
required: true
13+
schema:
14+
type: string
15+
- name: item_id
16+
description: Item ID
17+
in: path
18+
required: true
19+
schema:
20+
type: string
21+
responses:
22+
'201':
23+
description: Success
24+
content:
25+
application/json:
26+
schema:
27+
type: array
28+
items:
29+
$ref: '#/components/schemas/B2B_Sale'
30+
'401':
31+
description: "Not Authorized"

0 commit comments

Comments
 (0)