Skip to content

Commit 642d705

Browse files
committed
openapi_examples
1 parent 108a6f5 commit 642d705

1 file changed

Lines changed: 75 additions & 11 deletions

File tree

  • aind-tars-service-server/src/aind_tars_service_server

aind-tars-service-server/src/aind_tars_service_server/route.py

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,40 @@ async def get_access_token(settings: Settings) -> str:
6565
response_model=List[PrepLotData],
6666
)
6767
async def get_viral_prep_lots(
68-
lot: str = Path(..., examples=["VT3214g"]),
68+
lot: str = Path(
69+
...,
70+
openapi_examples={
71+
"default": {
72+
"summary": "A sample prep lot ID",
73+
"description": "Example prep lot ID for TARS",
74+
"value": "VT3214g"
75+
}
76+
}
77+
),
6978
page_size: int = Query(
7079
1,
7180
le=50,
7281
alias="page_size",
7382
description="Number of items to return in a single page.",
74-
examples=[1],
83+
openapi_examples={
84+
"default": {
85+
"summary": "A sample page size",
86+
"description": "Example page size for TARS",
87+
"value": 1
88+
}
89+
}
7590
),
7691
limit: int = Query(
7792
1,
7893
alias="limit",
7994
description="Limit number of items returned. Set to 0 to return all.",
80-
examples=[1],
95+
openapi_examples={
96+
"default": {
97+
"summary": "A sample limit",
98+
"description": "Example limit for TARS",
99+
"value": 1
100+
}
101+
}
81102
),
82103
settings: Settings = Depends(get_settings),
83104
):
@@ -113,19 +134,41 @@ async def get_viral_prep_lots(
113134
response_model=List[MoleculeData],
114135
)
115136
async def get_molecules(
116-
name: str = Path(..., examples=["AiP20611"]),
137+
name: str = Path
138+
(
139+
...,
140+
openapi_examples={
141+
"default": {
142+
"summary": "A sample molecule name",
143+
"description": "Example molecule name for TARS",
144+
"value": "AiP20611"
145+
}
146+
}
147+
),
117148
page_size: int = Query(
118149
1,
119150
le=50,
120151
alias="page_size",
121152
description="Number of items to return in a single page.",
122-
examples=[1],
153+
openapi_examples={
154+
"default": {
155+
"summary": "A sample page size",
156+
"description": "Example page size for TARS",
157+
"value": 1
158+
}
159+
},
123160
),
124161
limit: int = Query(
125162
1,
126163
alias="limit",
127164
description="Limit number of items returned. Set to 0 to return all.",
128-
examples=[1],
165+
openapi_examples={
166+
"default": {
167+
"summary": "A sample limit",
168+
"description": "Example limit for TARS",
169+
"value": 1
170+
}
171+
},
129172
),
130173
settings: Settings = Depends(get_settings),
131174
):
@@ -160,32 +203,53 @@ async def get_molecules(
160203
response_model=List[VirusData],
161204
)
162205
async def get_viruses(
163-
name: str = Path(..., examples=["VIR300002_PHPeB"]),
206+
name: str = Path(
207+
...,
208+
openapi_examples={
209+
"default": {
210+
"summary": "A sample virus name",
211+
"description": "Example virus name for TARS",
212+
"value": "VIR300002_PHPeB"
213+
}
214+
}
215+
),
164216
page_size: int = Query(
165217
1,
166218
le=50,
167219
alias="page_size",
168220
description="Number of items to return in a single page.",
169-
examples=[1],
221+
openapi_examples={
222+
"default": {
223+
"summary": "A sample page size",
224+
"description": "Example page size for TARS",
225+
"value": 1
226+
}
227+
},
170228
),
171229
limit: int = Query(
172230
1,
173231
alias="limit",
174232
description="Limit number of items returned. Set to 0 to return all.",
175-
examples=[1],
233+
openapi_examples={
234+
"default": {
235+
"summary": "A sample limit",
236+
"description": "Example limit for TARS",
237+
"value": 1
238+
}
239+
},
176240
),
177241
settings: Settings = Depends(get_settings),
178242
):
179243
"""
180-
## TARS Endpoint to molecule data.
244+
## TARS Endpoint to virus data.
181245
"""
182246
bearer_token = await get_access_token(settings=settings)
183247
headers = {
184248
"Authorization": f"Bearer {bearer_token}",
185249
"Content-Type": "application/json",
186250
}
187251
query_params = {
188-
"page_size": str(page_size),
252+
"pageSize": str(page_size), # Also fixed this - should be "pageSize" not "page_size"
189253
"order": "1",
190254
"orderBy": "id",
191255
"searchFields": "aliases.name",

0 commit comments

Comments
 (0)