Add API documentation for get car events on x way

This commit is contained in:
David Eder 2021-06-17 09:49:30 +02:00
parent 4d30f79900
commit 4a38a3a4a7
3 changed files with 27 additions and 13 deletions

View File

@ -18,7 +18,7 @@ export class RestService {
}
getCarEvents(vin) {
return this.http.get(this.currentLocation + 'car_events?vin=' + vin, {observe: 'response'});
return this.http.get(this.currentLocation + 'car_events/?vin=' + vin, {observe: 'response'});
}
getTrafficLights() {

View File

@ -3,3 +3,4 @@ Flask-Cors
requests
Flask-PyMongo
jsonify
flask_restx

View File

@ -1,19 +1,32 @@
import flask
import flask_restx
import requests
from bson import json_util
from flask import Flask
from flask import Flask, jsonify
from flask_cors import CORS
from flask import request
import json;
app = Flask(__name__)
CORS(app)
api_bp = flask.Blueprint("api", __name__, url_prefix="/api/v1/resources")
API = flask_restx.Api(api_bp)
app.register_blueprint(api_bp)
NAMESPACE = API.namespace("car_events")
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
EVENT_STORE_URL = 'http://eventstore:5001/api/keys/'
@app.route('/api/v1/resources/car_events', methods=['GET'])
def get_cars_events():
@NAMESPACE.route('/')
class CarsEvents(flask_restx.Resource):
@NAMESPACE.doc(params={'vin': {'description': 'Vehicle Identifier Number of car',
'type': 'String', 'default': '5GZCZ43D13S812715'}})
def get(self):
vin = request.args.get('vin')
try:
@ -24,7 +37,7 @@ def get_cars_events():
print("Is the EVENT_STORE_URL running and reachable?")
raise e
return json_util.dumps(cars)
return jsonify(cars)
@app.route('/api/v1/resources/traffic_light_events', methods=['GET'])