Skip to content

Commit d9a1552

Browse files
authored
Merge branch 'main' into anomaly-explanation
2 parents c81694d + 0f1a368 commit d9a1552

File tree

9 files changed

+109
-25
lines changed

9 files changed

+109
-25
lines changed

compiler/src/steps/validate-rest-spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,35 @@ export default async function validateRestSpec (model: model.Model, jsonSpec: Ma
6868
}
6969
}
7070

71+
// are all path parameters properly required or optional?
72+
let urlPartsRequired = new Set(urlParts)
73+
// A part is considered required if it is included in
74+
// every path for the API endpoint.
75+
for (const path of spec.url.paths) {
76+
if (path.parts == null) {
77+
// No parts means that all path parameters are optional!
78+
urlPartsRequired = new Set()
79+
break
80+
}
81+
urlPartsRequired = new Set([...Object.keys(path.parts)].filter((x) => urlPartsRequired.has(x)))
82+
}
83+
84+
// transform [{name: ..., required: ...}] -> {name: {required: ...}}
85+
const pathPropertyMap: Record<string, model.Property> = requestProperties.path.reduce((prev, prop) => ({ ...prev, [prop.name]: prop }), {})
86+
for (const name of pathProperties) {
87+
// okay to skip if it's not included since this scenario
88+
// is covered above with a different error.
89+
if (!urlParts.includes(name)) {
90+
continue
91+
}
92+
// Find the mismatches between the specs
93+
if (urlPartsRequired.has(name) && !pathPropertyMap[name].required) {
94+
errors.addEndpointError(endpoint.name, 'request', `${endpoint.request.name}: path parameter '${name}' is required in the json spec`)
95+
} else if (!urlPartsRequired.has(name) && pathPropertyMap[name].required) {
96+
errors.addEndpointError(endpoint.name, 'request', `${endpoint.request.name}: path parameter '${name}' is optional in the json spec`)
97+
}
98+
}
99+
71100
if (spec.params != null) {
72101
const params = Object.keys(spec.params)
73102
const queryProperties = requestProperties.query.map(property => property.name)

output/schema/schema.json

Lines changed: 31 additions & 17 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: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

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

specification/_global/rank_eval/RankEvalRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface Request extends RequestBase {
3434
* Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard (`*`) expressions are supported.
3535
* To target all data streams and indices in a cluster, omit this parameter or use `_all` or `*`.
3636
*/
37-
index: Indices
37+
index?: Indices
3838
}
3939
query_parameters: {
4040
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"semantic_search": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-search.html",
5+
"description": "Semantic search API using dense vector similarity"
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"],
11+
"content_type": ["application/json"]
12+
},
13+
"url": {
14+
"paths": [
15+
{
16+
"path": "/{index}/_semantic_search",
17+
"methods": ["GET", "POST"],
18+
"parts": {
19+
"index": {
20+
"type": "list",
21+
"description": "A comma-separated list of index names to search; use `_all` to perform the operation on all indices"
22+
}
23+
}
24+
}
25+
]
26+
},
27+
"params": {
28+
"routing": {
29+
"type": "list",
30+
"description": "A comma-separated list of specific routing values"
31+
}
32+
},
33+
"body": {
34+
"description": "The search definition"
35+
}
36+
}
37+
}

specification/_types/mapping/Property.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import {
7979
} from '@_types/mapping/geo'
8080

8181
export class PropertyBase {
82-
local_metadata?: Metadata
8382
/**
8483
* Metadata about the field.
8584
* @doc_id mapping-meta-field

specification/fleet/msearch/MultiSearchRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface Request extends RequestBase {
4343
/**
4444
* A single target to search. If the target is an index alias, it must resolve to a single index.
4545
*/
46-
index: IndexName | IndexAlias
46+
index?: IndexName | IndexAlias
4747
}
4848
query_parameters: {
4949
/**

specification/ml/clear_trained_model_deployment_cache/MlClearTrainedModelDeploymentCacheRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ export interface Request extends RequestBase {
3737
/**
3838
* The unique identifier of the trained model.
3939
*/
40-
model_id?: Id
40+
model_id: Id
4141
}
4242
}

0 commit comments

Comments
 (0)