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

Function validate_api_spec

pants-plugins/api_spec/rules.py:118–161  ·  view source on GitHub ↗
(
    request: ValidateAPISpecRequest.Batch,
    subsystem: ValidateApiSpec,
)

Source from the content-addressed store, hash-verified

116 level=LogLevel.DEBUG,
117)
118async def validate_api_spec(
119 request: ValidateAPISpecRequest.Batch,
120 subsystem: ValidateApiSpec,
121) -> LintResult:
122 source_files_get = Get(
123 SourceFiles,
124 SourceFilesRequest(field_set.source for field_set in request.elements),
125 )
126
127 config_files_get = Get(ConfigFiles, ConfigFilesRequest, subsystem.config_request())
128
129 # We use a pex to actually validate the api spec with an external script.
130 # Validation cannot be inlined here because it needs to import the st2 code.
131 # (the script location is defined on the ValidateApiSpec subsystem)
132 pex_get = Get(VenvPex, PexFromTargetsRequest, subsystem.pex_request())
133
134 source_files, config_files, pex = await MultiGet(
135 source_files_get, config_files_get, pex_get
136 )
137
138 input_digest = await Get(
139 Digest,
140 MergeDigests((config_files.snapshot.digest, source_files.snapshot.digest)),
141 )
142
143 process_result = await Get(
144 FallibleProcessResult,
145 VenvPexProcess(
146 pex,
147 argv=(
148 "--config-file",
149 subsystem.config_file,
150 # TODO: Uncomment these as part of a project to fix the (many) issues it identifies.
151 # We can uncomment --validate-defs (and possibly --verbose) once the spec defs are valid.
152 # "--validate-defs", # check for x-api-model in definitions
153 # "--verbose", # show model definitions on failure (only applies to --validate-defs)
154 ),
155 input_digest=input_digest,
156 description="Validating openapi.yaml api spec",
157 level=LogLevel.DEBUG,
158 ),
159 )
160
161 return LintResult.create(request, process_result)
162
163
164def rules():

Callers

nothing calls this directly

Calls 3

config_requestMethod · 0.80
createMethod · 0.80
pex_requestMethod · 0.45

Tested by

no test coverage detected