diff --git a/Makefile b/Makefile index 40e6f27d3..21ab05eb3 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,10 @@ format: ## Format the code into unified format schema: ## Generate OpenAPI schema file uv run scripts/generate_openapi_schema.py docs/openapi.json -openapi-doc: docs/openapi.json ## Generate OpenAPI documentation - openapi-to-markdown --input_file docs/openapi.json --output_file docs/output.md +openapi-doc: docs/openapi.json scripts/fix_openapi_doc.py ## Generate OpenAPI documentation + openapi-to-markdown --input_file docs/openapi.json --output_file output.md + python3 scripts/fix_openapi_doc.py < output.md > docs/output.md + rm output.md # TODO uv migration requirements.txt: pyproject.toml pdm.lock ## Generate requirements.txt file containing hashes for all non-devel packages diff --git a/docs/output.md b/docs/output.md index 8142578c2..5057e90d6 100644 --- a/docs/output.md +++ b/docs/output.md @@ -26,8 +26,7 @@ Handle request to the / endpoint. | Status Code | Description | Component | |-------------|-------------|-----------| -| 200 | Successful Response | string - | +| 200 | Successful Response | string | ## GET `/v1/info` > **Info Endpoint Handler** @@ -48,8 +47,7 @@ Returns: | Status Code | Description | Component | |-------------|-------------|-----------| -| 200 | Successful Response | [InfoResponse](#inforesponse) - | +| 200 | Successful Response | [InfoResponse](#inforesponse) | ## GET `/v1/models` > **Models Endpoint Handler** @@ -76,7 +74,6 @@ Returns: |-------------|-------------|-----------| | 200 | Successful Response | [ModelsResponse](#modelsresponse) | | 503 | Connection to Llama Stack is broken | | - ## POST `/v1/query` > **Query Endpoint Handler** @@ -396,8 +393,7 @@ Prometheus format. | Status Code | Description | Component | |-------------|-------------|-----------| -| 200 | Successful Response | string - | +| 200 | Successful Response | string | --- # 📋 Components diff --git a/scripts/fix_openapi_doc.py b/scripts/fix_openapi_doc.py new file mode 100755 index 000000000..9012cc7dc --- /dev/null +++ b/scripts/fix_openapi_doc.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +"""Filter to fix the generated OpenAPI documentation.""" + +import fileinput + +TABLE_ROW_CONTINUATION_LINE = " |" + +lines = list(fileinput.input()) + +lines_count = len(lines) + +for i in range(lines_count): + current_line = lines[i].rstrip("\r\n") + + # limit check + if i == lines_count - 1: + print(current_line) + break + + # the next line must exists -> read it + next_line = lines[i + 1].rstrip("\r\n") + + # skip the continuation line as it was used already + # during previous line processing + if current_line == TABLE_ROW_CONTINUATION_LINE: + continue + + # check if table row continuation line is present + if next_line == TABLE_ROW_CONTINUATION_LINE: + print(current_line + TABLE_ROW_CONTINUATION_LINE) + else: + print(current_line)