Skip to content

Commit 7d5c272

Browse files
Merge remote-tracking branch 'origin/main' into openshift-ai-integration
2 parents 8c4fd6d + 899b8a4 commit 7d5c272

File tree

8 files changed

+124
-156
lines changed

8 files changed

+124
-156
lines changed

compiler/src/steps/validate-model.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ const privateNamespaces = ['_internal', 'profiling']
4545
* Any inconsistency is logged as an error.
4646
*
4747
* Missing validations:
48-
* - verify uniqueness of property names in the inheritance chain
4948
* - verify that request parents don't define properties (would they be path/request/body properties?)
5049
* - verify that unions can be distinguished in a JSON stream (otherwise they should be inheritance trees)
5150
*/
5251
export default async function validateModel (apiModel: model.Model, restSpec: Map<string, JsonSpec>, errors: ValidationErrors): Promise<model.Model> {
53-
// Fail hard if the FAIL_HARD env var is defined
54-
const failHard = process.env.FAIL_HARD != null
55-
5652
const initialTypeCount = apiModel.types.length
5753

5854
// Returns the fully-qualified name of a type name
@@ -87,13 +83,20 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
8783
function modelError (msg: string): void {
8884
const fullMsg = (context.length === 0) ? msg : context.join(' / ') + ' - ' + msg
8985

86+
let ignored = false
9087
if (currentEndpoint != null) {
91-
errors.addEndpointError(currentEndpoint, currentPart, fullMsg)
88+
ignored = errors.addEndpointError(currentEndpoint, currentPart, fullMsg)
89+
if (!ignored) {
90+
console.error(currentEndpoint, currentPart, fullMsg)
91+
}
9292
} else {
9393
errors.addGeneralError(fullMsg)
94+
console.error(fullMsg)
9495
}
9596

96-
errorCount++
97+
if (!ignored) {
98+
errorCount++
99+
}
97100
}
98101

99102
// ----- Type definition management
@@ -206,8 +209,8 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
206209
const danglingTypesCount = initialTypeCount - apiModel.types.length
207210
console.info(`Model validation: ${typesSeen.size} types visited, ${danglingTypesCount} dangling types.`)
208211

209-
if (errorCount > 0 && failHard) {
210-
throw new Error('Model is inconsistent. Check logs for details')
212+
if (errorCount > 0) {
213+
throw new Error('Model is inconsistent.')
211214
}
212215

213216
return apiModel

compiler/src/validation-errors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ export class ValidationErrors {
3838
}
3939

4040
/** Add some error information relative to an endpoint's request or response */
41-
addEndpointError (endpoint: string, part: 'request' | 'response', message: string): void {
41+
addEndpointError (endpoint: string, part: 'request' | 'response', message: string): boolean {
4242
if (IGNORED_ERRORS.includes(message)) {
43-
return
43+
return true
4444
}
4545

4646
let error = this.endpointErrors[endpoint]
@@ -50,6 +50,7 @@ export class ValidationErrors {
5050
}
5151

5252
error[part].push(message)
53+
return false
5354
}
5455

5556
/** Add a general error, unrelated to an endpoint */

output/openapi/elasticsearch-openapi.json

Lines changed: 27 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 27 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 39 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"endpointErrors": {},
33
"generalErrors": [
4-
"ResponseBody is present in multiple namespaces: _global.search and ml.evaluate_data_frame",
54
"Dangling type '_global.scripts_painless_execute:PainlessExecutionPosition'",
65
"Dangling type '_global.scripts_painless_execute:PainlessScript'",
76
"Dangling type '_global.search._types:HitMetadata'",

output/typescript/types.ts

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/ml/evaluate_data_frame/MlEvaluateDataFrameResponse.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,20 @@ import {
2424
} from './types'
2525

2626
export class Response {
27-
/** @codegen_name result */
28-
body: ResponseBody
29-
}
30-
31-
/** @variants container */
32-
export class ResponseBody {
33-
/**
34-
* Evaluation results for a classification analysis.
35-
* It outputs a prediction that identifies to which of the classes each document belongs.
36-
*/
37-
classification?: DataframeClassificationSummary
38-
/**
39-
* Evaluation results for an outlier detection analysis.
40-
* It outputs the probability that each document is an outlier.
41-
*/
42-
outlier_detection?: DataframeOutlierDetectionSummary
43-
/**
44-
* Evaluation results for a regression analysis which outputs a prediction of values.
45-
*/
46-
regression?: DataframeRegressionSummary
27+
body: {
28+
/**
29+
* Evaluation results for a classification analysis.
30+
* It outputs a prediction that identifies to which of the classes each document belongs.
31+
*/
32+
classification?: DataframeClassificationSummary
33+
/**
34+
* Evaluation results for an outlier detection analysis.
35+
* It outputs the probability that each document is an outlier.
36+
*/
37+
outlier_detection?: DataframeOutlierDetectionSummary
38+
/**
39+
* Evaluation results for a regression analysis which outputs a prediction of values.
40+
*/
41+
regression?: DataframeRegressionSummary
42+
}
4743
}

0 commit comments

Comments
 (0)