Skip to content

Commit b97849f

Browse files
authored
Merge pull request #208 from hubmapconsortium/entity-api-schema-template
Entity api schema template
2 parents 8094b34 + 300a313 commit b97849f

19 files changed

+4855
-6
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ src/VERSION
2828
#ignore eclipse files
2929
.project
3030
.pydevproject
31+
32+
#ignore PyCharm files
33+
.idea/
34+
../.idea/
35+
venv
36+
37+
#ignore test venv
38+
**/testenv/

entity-api-spec.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ components:
4343
description: "The name of the antibody."
4444
channel_id:
4545
type: string
46-
description: "The assay specific identifier for the channel corresponding to the antibody."
46+
description: "The assay specific identifier for the channel corresponding to the antibody."
4747
conjugated_cat_number:
4848
type: string
4949
description: "An antibody may be conjugated to a fluorescent tag or a metal tag for detection. Conjugated antibodies may be purchased from commercial providers. Blank if not applicable."
@@ -445,7 +445,7 @@ components:
445445
- snatacseq
446446
- snrnaseq
447447
- tissue_lysate
448-
- wgs
448+
- wgs
449449
description: "A code representing the type of specimen. Must be one of the codes specified in: [tissue sample types](https://github.com/hubmapconsortium/search-api/blob/master/src/search-schema/data/definitions/enums/tissue_sample_types.yaml)"
450450
specimen_type_other:
451451
type: string
@@ -941,7 +941,7 @@ security:
941941
paths:
942942
'/entities/{id}':
943943
get:
944-
summary: Retrieve a provenance entity by id. Entity types of Donor, Sample and Datasets.
944+
summary: Retrieve a provenance entity by id. Entity types of Donor, Sample and Datasets.
945945
security:
946946
- bearerAuth: []
947947
parameters:
@@ -1329,7 +1329,7 @@ paths:
13291329
description: Internal error
13301330
'/doi/redirect/{id}':
13311331
get:
1332-
summary: Redirect a request from a doi service
1332+
summary: Redirect a request from a doi service
13331333
parameters:
13341334
- name: id
13351335
in: path
@@ -1421,5 +1421,4 @@ paths:
14211421
'404':
14221422
description: The target dataset could not be found
14231423
'500':
1424-
description: Internal error
1425-
1424+
description: Internal error

src/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ neo4j==4.2.1
44
prov==2.0.0
55
Werkzeug==1.0.1
66

7+
# For schema templating
8+
nested-lookup==0.2.22
9+
710
# The commons package requires requests>=2.22.0 and PyYAML>=5.3.1
811
requests==2.25.1
912
PyYAML==5.4.1
1013

1114
# The branch name of commons to be used during image build
1215
# Default is master branch specified in docker-compose.yml if not set
1316
git+git://github.com/hubmapconsortium/commons.git@${COMMONS_BRANCH}#egg=hubmap-commons
17+
18+
# For unit test
19+
nose2==0.10.0

src/schema_templating/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Schema Templating
2+
3+
A collection of files and scripts used to modifying Openapi specification files in yaml format.
4+
5+
## How to run
6+
7+
Run build-schema.sh in this directory with 1 argument: a file path to a yaml schema "template" file.
8+
The directory example-yaml-templates has a number of yaml files that have tags of the pattern "X-replace-..."
9+
When build-schema.sh is run with the path to the desired file, general_schema_template_transformer.py will be executed
10+
The X-replace tags have under them url's or direct file paths to the location of yaml files where desired information is located.
11+
If that yaml file also has X-replace tags, this process will repeat until all replacements are made. The final result
12+
is output as a new yaml file called my-spec.yaml. If build-schema.sh does not receive precisely 1 argument, an error is thrown.
13+
If the file given as an argument does not exist, an error is also thrown.
14+
15+
### Usage
16+
17+
````
18+
./build-schema.sh example-yaml-templates/search-api-spec-TEMPLATE.yaml
19+
````
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
FILE="$1"
4+
SCRIPTDIRECTORY=$(dirname ${BASH_SOURCE[0]})
5+
if (( $# == 1)); then
6+
if test -f "$FILE"; then
7+
${SCRIPTDIRECTORY}/general_schema_template_transformer.py $FILE > ${SCRIPTDIRECTORY}/my-spec.yaml
8+
var=$( cat ${SCRIPTDIRECTORY}/my-spec.yaml)
9+
else
10+
echo "$FILE does not exist"
11+
fi
12+
else
13+
echo "$# arguments were passed. Please pass exactly 1 argument that is the name of an existing file"
14+
fi
15+
if test -f "./my-spec.yaml"; then
16+
if test -z "$var"; then
17+
rm $SCRIPTDIRECTORY/my-spec.yaml
18+
fi
19+
fi
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
x-ref-openapi: 3.0.0
2+
x-ref-info:
3+
x-ref-description: 'The HuBMAP Antibody API is a standard RESTful web service with create operations.<br><br>'
4+
x-ref-version: 1.0.0
5+
x-ref-title: HuBMAP Antibody API
6+
x-ref-contact:
7+
x-ref-name: HuBMAP Help Desk
8+
x-ref-email: [email protected]
9+
x-ref-license:
10+
x-ref-name: MIT License
11+
x-ref-url: 'https://github.com/hubmapconsortium/antibody-api/blob/master/license.txt'
12+
x-ref-servers:
13+
- x-ref-url: 'https://antibody.api.hubmapconsortium.org'
14+
x-ref-components:
15+
x-ref-securitySchemes:
16+
x-ref-bearerAuth:
17+
x-ref-type: http
18+
x-ref-scheme: bearer
19+
x-ref-schemas:
20+
x-ref-Antibody:
21+
x-ref-type: object
22+
x-ref-properties:
23+
avr_url:
24+
type: string
25+
description: "The URL of the AVR PDF."
26+
protocols_io_doi:
27+
type: string
28+
description: "The protocols.io doi pointing the protocol under wich the sample was obtained and/or prepared."
29+
x-ref-uniprot_accession_number:
30+
x-ref-type: string
31+
target_name:
32+
type: string
33+
description: "The name of the antibody's target."
34+
rrid:
35+
type: string
36+
x-ref-antibody_name:
37+
x-ref-type: string
38+
x-ref-description: "The antibody's name."
39+
host_organism:
40+
type: string
41+
description: "The antibody's host organism."
42+
clonality:
43+
type: string
44+
enum:
45+
- monoclonal
46+
- polyclonal
47+
description: "One of the values: monoclonal, polyclonal."
48+
vendor:
49+
type: string
50+
description: "The antibody's vendor."
51+
catalog_number:
52+
type: string
53+
x-ref-lot_number:
54+
x-ref-type: string
55+
recombinant:
56+
type: boolean
57+
description: "True if the antibody is recombinant."
58+
organ_or_tissue:
59+
type: string
60+
description: "Organ or tissue affected."
61+
hubmap_platform:
62+
type: string
63+
description: "The assay employed for the antibody."
64+
submitter_orciid:
65+
type: string
66+
description: "The ORCID iD of the submitter."
67+
created_by_user_displayname:
68+
type: string
69+
description: "The name of the person or process authenticated when creating the object"
70+
created_by_user_email:
71+
type: string
72+
description: "The email address of the person or process authenticated when creating the object."
73+
created_by_user_sub:
74+
type: string
75+
description: "The subject id as provided by the authorization mechanism for the person or process authenticated when creating the object."
76+
group_uuid:
77+
type: string
78+
description: "The uuid of globus group which the user who created this antibody is a member of."
79+
x-ref-security:
80+
- x-ref-bearerAuth: []
81+
x-ref-paths:
82+
'/antibodies':
83+
post:
84+
summary: Create an antibody
85+
parameters:
86+
requestBody:
87+
content:
88+
application/json:
89+
schema:
90+
type: object
91+
properties:
92+
antibody:
93+
$ref: '#/components/schemas/Antibody'
94+
description: "The Antibody to be created."
95+
responses:
96+
'200':
97+
description: The antibody was successfully created and the new ID is returned
98+
content:
99+
application/json:
100+
schema:
101+
type: object
102+
properties:
103+
id:
104+
type: integer
105+
description: "The ID of the Antibody just created."
106+
'400':
107+
description: No JSON body supplied
108+
'401':
109+
description: The user's token has expired or the user did not supply a valid token
110+
'403':
111+
description: The user is not authorized to create the entity
112+
'406':
113+
description: The antibody data submitted did not pass validation
114+
'500':
115+
description: Internal error

0 commit comments

Comments
 (0)