-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add python to remove default Jersey WADL from yaml
Eclipse Jersey used by trace-server enables WADL [1] by default. Even when disabling the latter ([1]), Swagger (in server) keeps generating the corresponding endpoint paths in openapi.{json|yaml}. Add an executable python script, along with proper python support for it, that removes those WADL paths. Document usage of this simple script in README. Base the hereby introduced python support and initial use on [2]'s ways. [1] https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e13703 [2] https://github.com/theia-ide/tsp-python-client Signed-off-by: Marco Miller <marco.miller@ericsson.com>
- Loading branch information
1 parent
51cd9e1
commit 21d4382
Showing
6 changed files
with
67 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"python.formatting.provider": "autopep8", | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
autopep8 | ||
pylint |