()
| 88 | |
| 89 | |
| 90 | def 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 | |
| 122 | def teardown(): |
no test coverage detected