MCPcopy Create free account
hub / github.com/StackStorm/st2 / validate_spec

Function validate_spec

st2common/st2common/cmd/validate_api_spec.py:90–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89
90def validate_spec():
91 spec_file = cfg.CONF.spec_file
92 generate_spec = cfg.CONF.generate
93 validate_defs = cfg.CONF.validate_defs
94
95 if not os.path.exists(spec_file) and not generate_spec:
96 msg = (
97 "No spec file found in location %s. " % spec_file
98 + "Provide a valid spec file or "
99 + "pass --generate-api-spec to genrate a spec."
100 )
101 raise Exception(msg)
102
103 if generate_spec:
104 if not spec_file:
105 raise Exception("Supply a path to write to spec file to.")
106
107 spec_string = spec_loader.generate_spec("st2common", "openapi.yaml.j2")
108
109 with open(spec_file, "w") as f:
110 f.write(spec_string)
111 f.flush()
112
113 parser = prance.ResolvingParser(spec_file)
114 spec = parser.specification
115
116 if not validate_defs:
117 return True
118
119 return _validate_definitions(spec)
120
121
122def teardown():

Callers 1

mainFunction · 0.85

Calls 4

_validate_definitionsFunction · 0.85
existsMethod · 0.80
writeMethod · 0.80
flushMethod · 0.80

Tested by

no test coverage detected