diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef81b1e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.venv/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..620c3a6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.formatting.provider": "autopep8", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true +} \ No newline at end of file diff --git a/README.md b/README.md index 13eddc4..1c919f2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,18 @@ The specification should be edited with the [OpenAPI (Swagger) Editor extension] The latter extension is assumed for consistent formatting of the `./API.yaml` file over time. +### Setup + +To initialize a local virtual environment, type the following commands in the root directory: + +```shell +python3 -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +``` + +The virtual environment can be replaced with another local setup. + ### Alternate TSP version Above, `API.yaml` has been the manually documented TSP version up until now. @@ -39,6 +51,7 @@ In the meantime, Swagger has recently been added to trace-server. 1. Browse [to here][4] ([swagger][5]) or so to generate server's TSP. 1. Bring the resulting file over; e.g.: `mv ~/Downloads/openapi.yaml .` 1. Update the latter with its license information: `./openapi` +1. Remove the default Eclipse Jersey's WADL paths: `./openapi.py` 1. The resulting git diff may then be pushed for review, at will. [1] org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core diff --git a/openapi.py b/openapi.py new file mode 100755 index 0000000..1ca0cda --- /dev/null +++ b/openapi.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- +# +# The MIT License (MIT) +# +# Copyright (C) 2021 - Ericsson +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import re + +NAME = "openapi" +FILE = NAME + ".yaml" +TEMP = NAME + ".tmp" + +tmp = open(TEMP, 'w') +wadl = False +with open(FILE) as yaml: + for line in yaml: + if re.match(r'^\s\s/.+:$', line): + # line is a path; check if wadl to remove it: + wadl = "application.wadl" in line + elif wadl: + # wadl stops if no longer within a wadl path: + wadl = not re.match(r'^\S+:$', line) + if not wadl: + tmp.write(line) + +os.rename(TEMP, FILE) diff --git a/openapi.yaml b/openapi.yaml index 17c7b31..ed16682 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -706,29 +706,6 @@ paths: description: default response content: '*/*': {} - /application.wadl/{path}: - get: - operationId: getExternalGrammar - parameters: - - name: path - in: path - required: true - schema: - type: string - responses: - default: - description: default response - content: - application/xml: {} - /application.wadl: - get: - operationId: getWadl - responses: - default: - description: default response - content: - application/vnd.sun.wadl+xml: {} - application/xml: {} components: schemas: Filter: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..53543eb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +autopep8 +pylint