1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16+ from enum import Enum
17+ from inspect import isclass
18+
1619from apispec import APISpec
1720from apispec_webframeworks .flask import FlaskPlugin
18- from rucio .vcsversion import VERSION_INFO
21+ from rucio .db .sqla import constants
22+ from rucio .vcsversion import VERSION
1923from rucio .web .rest .flaskapi .v1 .main import application
2024
2125description_text = """Each resource can be accessed or modified using specially
8993"""
9094
9195
92- def collect_enums () -> dict :
96+ def collect_enums () -> dict :
9397 """Create a dictionary of all the enumerate types that can be used for spec API docs"""
9498 enum_specs = {}
95- from rucio .db .sqla import constants
96- from inspect import isclass
9799
98100 for k , v in constants .__dict__ .items ():
99- if isclass (v ):
100- try :
101- enum_specs [k ] = {
102- "type" : "string" ,
103- "enum" : [e .value for e in v ]
104- }
105- except TypeError :
101+ if isclass (v ) and issubclass (v , Enum ):
102+ try :
103+ enum_specs [k ] = {"type" : "string" , "enum" : [e .value for e in v ]}
104+ except TypeError :
106105 pass
107106
108107 return enum_specs
109108
109+
110110spec = APISpec (
111111 title = "Rucio" ,
112- version = VERSION_INFO [ "version" ] ,
112+ version = VERSION ,
113113 openapi_version = "3.0.2" ,
114114 plugins = [FlaskPlugin ()],
115115 info = {
@@ -134,7 +134,7 @@ def collect_enums() -> dict:
134134 "description" : "The Rucio Token obtained by one of the /auth endpoints." , # noqa: E501
135135 },
136136 },
137- "schemas" : collect_enums ()
137+ "schemas" : collect_enums (),
138138 },
139139 security = [{"AuthToken" : []}],
140140)
0 commit comments