diff --git a/.github/scripts/sync_openapi.py b/.github/scripts/sync_openapi.py deleted file mode 100644 index 2e390d1..0000000 --- a/.github/scripts/sync_openapi.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 -""" -Parses an OpenAPI YAML spec and updates the pages arrays in docs.json -for the given tab, matching each group name to its OpenAPI tag. - -Usage: sync_openapi.py -""" -import sys -import json -import yaml -from collections import defaultdict - -HTTP_METHODS = {'get', 'post', 'put', 'patch', 'delete', 'head', 'options'} - - -def extract_ops_by_tag(spec): - tag_ops = defaultdict(list) - for path, path_item in spec.get('paths', {}).items(): - for method, operation in path_item.items(): - if method.lower() not in HTTP_METHODS: - continue - if not isinstance(operation, dict): - continue - for tag in operation.get('tags', []): - tag_ops[tag].append(f"{method.upper()} {path}") - return tag_ops - - -def main(): - yaml_file, docs_json_file, tab_name = sys.argv[1], sys.argv[2], sys.argv[3] - - with open(yaml_file) as f: - spec = yaml.safe_load(f) - - tag_ops = extract_ops_by_tag(spec) - - with open(docs_json_file) as f: - docs = json.load(f) - - for tab in docs.get('navigation', {}).get('tabs', []): - if tab.get('tab') != tab_name: - continue - for group in tab.get('groups', []): - if 'openapi' not in group: - continue - group_name = group['group'] - group['pages'] = tag_ops.get(group_name, []) - break - - with open(docs_json_file, 'w') as f: - json.dump(docs, f, indent=2) - f.write('\n') - - -if __name__ == '__main__': - main() diff --git a/docs.json b/docs.json index 1a8e6de..67b6c0c 100644 --- a/docs.json +++ b/docs.json @@ -135,26 +135,9 @@ ] }, { - "group": "Search", - "openapi": "openapi/search-v6.yaml", - "pages": [ - "GET /6/{hashid}/_search", - "POST /6/{hashid}/_search", - "GET /6/{hashid}/_suggest", - "POST /6/{hashid}/_image_search", - "GET /6/{hashid}/_visually_similar" - ] - }, - { - "group": "Session & Events", + "group": "Endpoints", "openapi": "openapi/search-v6.yaml", - "pages": [ - "PUT /6/{hashid}/stats/init", - "PUT /6/{hashid}/stats/click", - "PUT /6/{hashid}/stats/cart/{session_id}", - "PUT /6/{hashid}/stats/redirect", - "PUT /6/{hashid}/stats/image" - ] + "pages": [] } ] }, @@ -184,64 +167,9 @@ ] }, { - "group": "Usage & Sessions", - "openapi": "openapi/stats-v2.yaml", - "pages": [ - "GET /api/v2/stats/inits", - "GET /api/v2/stats/inits/locations", - "GET /api/v2/stats/inits/users", - "GET /api/v2/stats/usage", - "GET /api/v2/stats/search_engine_users" - ] - }, - { - "group": "Searches", - "openapi": "openapi/stats-v2.yaml", - "pages": [ - "GET /api/v2/stats/searches", - "GET /api/v2/stats/searches/top", - "GET /api/v2/stats/searches/popular", - "GET /api/v2/stats/searches/locations", - "GET /api/v2/stats/results/top" - ] - }, - { - "group": "Clicks & Interactions", - "openapi": "openapi/stats-v2.yaml", - "pages": [ - "GET /api/v2/stats/clicks", - "GET /api/v2/stats/clicks/users", - "GET /api/v2/stats/clicked_items", - "GET /api/v2/stats/clicked_items/searches", - "GET /api/v2/stats/clicked_items/position", - "GET /api/v2/stats/redirects" - ] - }, - { - "group": "Conversions & Sales", - "openapi": "openapi/stats-v2.yaml", - "pages": [ - "GET /api/v2/stats/checkouts", - "GET /api/v2/stats/sales", - "POST /api/v2/stats/sales", - "GET /api/v2/stats/top-sales", - "POST /api/v2/stats/carts" - ] - }, - { - "group": "Features", + "group": "Endpoints", "openapi": "openapi/stats-v2.yaml", - "pages": [ - "GET /api/v2/stats/banners", - "GET /api/v2/stats/facets", - "GET /api/v2/stats/facets_by_day", - "GET /api/v2/stats/facets/top", - "GET /api/v2/stats/custom-results", - "GET /api/v2/stats/recommendations", - "GET /api/v2/stats/quizzes", - "GET /api/v2/stats/sector/{name}", - "POST /api/v2/stats/visit" - ] + "pages": [] } ] }, @@ -257,9 +185,7 @@ { "group": "Endpoints", "openapi": "openapi/recommendations-v1.yaml", - "pages": [ - "POST /api/widget/{widget_id}" - ] + "pages": [] } ] }, @@ -275,9 +201,7 @@ { "group": "Endpoints", "openapi": "openapi/category-merchandising-v1.yaml", - "pages": [ - "GET /category_merchandising/{hashid}" - ] + "pages": [] } ] }