Skip to content

Commit 1bf6ea5

Browse files
authored
Merge branch 'main' into fixing-index-create-partially
2 parents 779cdd2 + 64abc0a commit 1bf6ea5

File tree

15 files changed

+465
-96
lines changed

15 files changed

+465
-96
lines changed

compiler-rs/clients_schema/src/transform/expand_generics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ pub fn expand(model: IndexedModel, config: ExpandConfig) -> anyhow::Result<Index
211211

212212
expand_behaviors(&mut resp.behaviors, &mappings, model, ctx)?;
213213
expand_body(&mut resp.body, &mappings, model, ctx)?;
214-
215-
// TODO: exceptions
214+
215+
for exception in &mut resp.exceptions {
216+
expand_body(&mut exception.body, &mappings, model, ctx)?;
217+
}
216218

217219
Ok(resp.into())
218220
}

compiler/src/steps/validate-model.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,23 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
497497
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
498498
throw new Error(`Unknown kind: ${typeDef.body.kind}`)
499499
}
500+
501+
if (typeDef.exceptions != null) {
502+
for (const ex of typeDef.exceptions) {
503+
switch (ex.body.kind) {
504+
case 'properties':
505+
validateProperties(ex.body.properties, openGenerics, new Set<string>())
506+
break
507+
case 'value':
508+
validateValueOf(ex.body.value, openGenerics)
509+
break
510+
case 'no_body':
511+
// Nothing to validate
512+
break
513+
}
514+
}
515+
}
516+
500517
context.pop()
501518
}
502519

compiler/src/transform/expand-generics.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
Request,
2828
Response,
2929
Body,
30-
InstanceOf, Inherits, Property
30+
InstanceOf, Inherits, Property, ResponseException
3131
} from '../model/metamodel'
3232
import { readFile, writeFile } from 'fs/promises'
3333
import stringify from 'safe-stable-stringify'
@@ -293,6 +293,17 @@ export function expandGenerics (inputModel: Model, config?: ExpansionConfig): Mo
293293
return addIfNotSeen(resp.name, () => {
294294
const result = { ...resp }
295295
result.body = expandBody(resp.body, genericParamMapping(resp.generics, params))
296+
if (resp.exceptions != null) {
297+
result.exceptions = []
298+
for (const exception of resp.exceptions) {
299+
const except: ResponseException = {
300+
description: exception.description,
301+
statusCodes: exception.statusCodes,
302+
body: expandBody(exception.body, genericParamMapping(resp.generics, params))
303+
}
304+
result.exceptions.push(except)
305+
}
306+
}
296307
result.generics = undefined
297308
return result
298309
})

output/openapi/elasticsearch-openapi.json

Lines changed: 22 additions & 5 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: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)