Skip to content

Commit

Permalink
Fix for documentationof API 2.0 listing each endpoint twice (#59)
Browse files Browse the repository at this point in the history
* more sophisticated way to add the /charts/power endpoint to the API 2.0 blueprint
* more useful doc-categories for the pre-2.0 endpoints (was: User)
  • Loading branch information
nhoening committed Mar 11, 2021
1 parent 2bf1dd4 commit 388a8a7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
8 changes: 8 additions & 0 deletions documentation/changelog.rst
Expand Up @@ -3,6 +3,14 @@ FlexMeasures Changelog
**********************


v0.2.4 | March XX, 2021
===========================

Bugfixes
--------
* Documentation listed 2.0 API endpoints twice [see `PR #59 <http://www.github.com/SeitaBV/flexmeasures/pull/59>`_]


v0.2.3 | February 27, 2021
===========================

Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/api/v1/routes.py
Expand Up @@ -34,7 +34,7 @@
def get_meter_data():
"""API endpoint to get meter data.
.. :quickref: User; Download meter data from the platform
.. :quickref: Data; Download meter data from the platform
**Optional parameters**
Expand Down Expand Up @@ -99,7 +99,7 @@ def get_meter_data():
def post_meter_data():
"""API endpoint to post meter data.
.. :quickref: User; Upload meter data to the platform
.. :quickref: Data; Upload meter data to the platform
**Optional parameters**
Expand Down
10 changes: 5 additions & 5 deletions flexmeasures/api/v1_1/routes.py
Expand Up @@ -62,7 +62,7 @@
def get_connection():
"""API endpoint to get the user's connections as entity addresses ordered from newest to oldest.
.. :quickref: User; Retrieve entity addresses of connections
.. :quickref: Asset; Retrieve entity addresses of connections
**Example request**
Expand Down Expand Up @@ -115,7 +115,7 @@ def get_connection():
def post_price_data():
"""API endpoint to post price data.
.. :quickref: User; Upload price data to the platform
.. :quickref: Data; Upload price data to the platform
**Optional parameters**
Expand Down Expand Up @@ -203,7 +203,7 @@ def post_weather_data():
The sensor type is part of the unique entity address for each sensor, together with the sensor's latitude and longitude.
.. :quickref: User; Upload weather data to the platform
.. :quickref: Data; Upload weather data to the platform
**Optional parameters**
Expand Down Expand Up @@ -271,7 +271,7 @@ def post_weather_data():
def get_prognosis():
"""API endpoint to get prognosis.
.. :quickref: User; Download prognosis from the platform
.. :quickref: Data; Download prognosis from the platform
**Optional parameters**
Expand Down Expand Up @@ -339,7 +339,7 @@ def get_prognosis():
def post_prognosis():
"""API endpoint to post prognoses about meter data.
.. :quickref: User; Upload prognosis to the platform
.. :quickref: Data; Upload prognosis to the platform
**Optional parameters**
Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/api/v1_2/routes.py
Expand Up @@ -43,7 +43,7 @@
def get_device_message():
"""API endpoint to get device message.
.. :quickref: User; Download control signal from the platform
.. :quickref: Control; Download control signal from the platform
**Optional parameters**
Expand Down Expand Up @@ -101,7 +101,7 @@ def get_device_message():
def post_udi_event():
"""API endpoint to post UDI event.
.. :quickref: User; Upload flexibility constraints to the platform
.. :quickref: Control; Upload flexibility constraints to the platform
**Example request**
Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/api/v1_3/routes.py
Expand Up @@ -25,7 +25,7 @@
def get_device_message():
"""API endpoint to get device message.
.. :quickref: User; Download control signal from the platform
.. :quickref: Control; Download control signal from the platform
**Optional parameters**
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_device_message():
def post_udi_event():
"""API endpoint to post UDI event.
.. :quickref: User; Upload flexibility constraints to the platform
.. :quickref: Control; Upload flexibility constraints to the platform
**Example request A**
Expand Down
17 changes: 14 additions & 3 deletions flexmeasures/ui/__init__.py
@@ -1,6 +1,7 @@
import os

from flask import current_app, Flask, Blueprint
from flask.blueprints import BlueprintSetupState
from flask import send_from_directory
from flask_security import login_required, roles_accepted
import numpy as np
Expand Down Expand Up @@ -58,10 +59,20 @@ def favicon():
add_jinja_filters(app)
add_jinja_variables(app)

# re-register api blueprint so it'll register the chart views (the ones in views.charts)
app.register_blueprint(
flexmeasures_api_v2_0, url_prefix="/api/v2_0", first_registration=False
# Add our chart endpoint to the Api 2.0 blueprint.
# This lets it show up in the API list twice, but that seems to be the best way for now (see below).
# Also, we'll reconsider where these charts endpoints should really live when we make more.
from flexmeasures.ui.views.charts import get_power_chart

# We cannot call this directly on the blueprint, as that only defers to registration.
# Re-registering the blueprint leads to all endpoints being listed twice.
blueprint_state = BlueprintSetupState(
flexmeasures_api_v2_0,
app,
{"url_prefix": "/api/v2_0"},
first_registration=False,
)
blueprint_state.add_url_rule("/charts/power", None, get_power_chart)


def register_rq_dashboard(app):
Expand Down

0 comments on commit 388a8a7

Please sign in to comment.