Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #34

Merged
merged 5 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,6 @@ ENV/

.idea

openpoiservice/server/ops_settings.yml
openpoiservice/server/ops_settings.yml
osm_1
osm_2
13 changes: 13 additions & 0 deletions openpoiservice/server/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# openpoiservice/server/api/__init__.py

error_codes = {
4000: 'Invalid JSON object in request',
4001: 'Category or category group ids missing',
4002: 'Geometry is missing',
4003: 'Bounding box and or geojson not present in request',
4004: 'Buffer is missing',
4005: 'Geometry length does not meet the restrictions',
4006: 'Unsupported HTTP method',
4007: 'GeoJSON issue',
4008: 'Geometry size does not meet the restrictions',
4099: 'Unknown internal error'
}
30 changes: 16 additions & 14 deletions openpoiservice/server/api/api_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from openpoiservice.server.api import error_codes


class InvalidUsage(Exception):
status_code = 400

def __init__(self, message, status_code=None, payload=None):
def __init__(self, status_code=500, error_code=None, message=None):
"""
INVALID_JSON_FORMAT = 400
MISSING_PARAMETER = 401
INVALID_PARAMETER_FORMAT = 402
INVALID_PARAMETER_VALUE = 403
PARAMETER_VALUE_EXCEEDS_MAXIMUM = 404
UNKNOWN = 499

:param message: custom message
:type message: string

Expand All @@ -22,13 +17,20 @@ def __init__(self, message, status_code=None, payload=None):

# type: (object, object, object) -> object
Exception.__init__(self)
self.message = message

if status_code is not None:
self.status_code = status_code
self.payload = payload

if message is None:
message = error_codes[error_code]
else:
message = message

self.error = {
"code": error_code,
"message": message
}

def to_dict(self):
rv = dict(self.payload or ())
rv['message'] = self.message
rv = dict(self.error or ())
return rv

31 changes: 19 additions & 12 deletions openpoiservice/server/api/pois_post.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,33 @@ paths:
#- $ref: '#/definitions/LocationsBodyList'
responses:
200:
description: Standard response for successfully processed requests.
description: "Standard response for successfully processed requests."
schema:
$ref: '#/definitions/LocationsPoiResponse'
# oneOf:
#- $ref: '#/definitions/LocationsPoiResponse'
#- $ref: '#/definitions/LocationsStatsResponse'
#- $ref: '#/definitions/LocationsListResponse'
400:
description: Unable to parse JSON request.
401:
description: Required parameter is missing.
402:
description: Invalid parameter format.
description: "Authorization field missing."
403:
description: Invalid parameter value.
404:
description: Parameter value exceeds the maximum allowed limit.
499:
description: Unknown internal error.

description: "Key not authorised."
500:
description: |
An unexpected error was encountered and more detailed internal
errorcode is provided.
| Internal Code | Description |
|:-------------:|----------------------------------------------------|
| 4000 | Invalid JSON object in request |
| 4001 | Category or category group ids missing |
| 4002 | Geometry is missing |
| 4003 | Bounding box and or geojson not present in request |
| 4004 | Buffer is missing |
| 4005 | Geometry length does not meet the restrictions |
| 4006 | Unsupported HTTP method |
| 4007 | GeoJSON parsing error |
| 4008 | Geometry size does not meet the restrictions |
| 4099 | Unknown internal error |
securityDefinitions:
UserSecurity:
name: "api_key"
Expand Down
Loading