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

[PAN-2158] Integrate API docs #101

Closed
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,13 @@ jobs:
with:
servicenode-path: ${{ env.PANTOS_SERVICE_NODE }}
servicenode-version: 'local'

openapi:
name: OpenAPI docs generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pantos-io/ci-workflows/.github/actions/install-python-deps@v1
- name: Build OpenAPI
run: |
make OPEN_API_OUTPUT=open_api.json docs
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ check-version:
echo "Version check passed" ; \
fi

.PHONY: docs
docs:
poetry run python3 -m pantos.servicenode.docs $(OPEN_API_OUTPUT)

.PHONY: dist
dist: tar wheel debian

Expand Down
9 changes: 9 additions & 0 deletions pantos/servicenode/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"""Logger for this module."""


def create_dummy_application() -> flask.Flask:
"""Create a useless dummy web app avoiding all the initialization
of additional components. Mainly used for docs generation.

"""
from pantos.servicenode.restapi import flask_app
return flask_app


def create_application() -> flask.Flask:
"""Create the service node application.

Expand Down
21 changes: 21 additions & 0 deletions pantos/servicenode/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,27 @@ class _Bids(flask_restful.Resource):

"""
def get(self) -> flask.Response:
"""
A simple GET endpoint that returns a greeting.
---
parameters:
- in: query
name: source_blockchain
schema:
$ref: '#/components/schemas/_Bids/properties/source_blockchain'
required: true
description: Numeric ID of the user to get
- in: query
name: destination_blockchain
schema:
$ref: '#/components/schemas/_Bids/properties/destination_blockchain'
required: true
description: Numeric ID of the user to get
responses:
200:
description: 'ok'
"""

try:
query_arguments = flask_restful.request.args
bids_parameter = _BidsSchema().load(query_arguments)
Expand Down
Loading
Loading