Skip to content

Commit

Permalink
Fix #154
Browse files Browse the repository at this point in the history
Changes to be committed:
	modified:   api/views.py
  • Loading branch information
HadleyKing committed May 4, 2023
1 parent 953d84a commit 520a7d3
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,31 +1026,54 @@ class ApiObjectsSearch(APIView):
--------------------
Search for available BCO objects that match criteria.
`type` can be one of 3 different values => mine | prefix | bco_id
`search` should be an empty string if you are doing the mine search as that is for "My BCOs"
For prefix `search` should be the name of the prefix.
For `bco_id` it should be some substring that is present in the desired `bco_id` or SET of `bco_ids`
Shell
```shell
curl -X POST "http://localhost:8000/api/objects/search/" -H "accept: application/json" -H "Authorization: Token ${token}" -H "Content-Type: application/json" -d "{\"POST_api_objects_search\":[{\"type\": \"prefix\",\"search\": \"TEST\"}]}"
```
JavaScript
```javascript
axios.post("http://localhost:8000/api/objects/search/", {
"POST_api_objects_search":[
{
"type": "prefix",
"search": "TEST"
}
]
}, {
headers: {
"Authorization": "Token ${token},
"Content-Type": "application/json"
}
});
```
"""

# authentication_classes = []
# permission_classes = []
# TODO: Need to get the schema that is being sent here from FE
request_body = openapi.Schema(
type=openapi.TYPE_OBJECT,
title="BCO Publication Schema",
description="Publish description.",
title="BCO Search Schema",
description="Search for BCOs",
properties={
"x": openapi.Schema(
type=openapi.TYPE_STRING, description="Description of X"
"type": openapi.Schema(
type=openapi.TYPE_STRING, description="Type of search to perform"
),
"y": openapi.Schema(
type=openapi.TYPE_STRING, description="Description of Y"
"search": openapi.Schema(
type=openapi.TYPE_STRING, description="Search value"
),
},
)

@swagger_auto_schema(
request_body=request_body,
responses={
200: "BCO publication is successful.",
400: "Bad request.",
403: "Invalid token.",
200: "Search successful.",
404: "That prefix was not found on this server."
},
tags=["BCO Management"],
)
Expand Down

0 comments on commit 520a7d3

Please sign in to comment.