Skip to content

[8.19] [OpenAPI generator] add transformSchemaName config options (#250857)#252472

Merged
janmonschke merged 2 commits intoelastic:8.19from
janmonschke:backport/8.19/pr-250857
Feb 10, 2026
Merged

[8.19] [OpenAPI generator] add transformSchemaName config options (#250857)#252472
janmonschke merged 2 commits intoelastic:8.19from
janmonschke:backport/8.19/pr-250857

Conversation

@janmonschke
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

…#250857)

## Summary

If a yaml definition defines the type names in lowercase, like in the
cases codebase, the generator would generate lowercase type/schema
names. This is against our eslint rules.

```yaml
in: query
name: assignees
description: >
  Filters the returned cases by assignees.
  Valid values are `none` or unique identifiers for the user profiles.
  These identifiers can be found by using the suggest user profile API.
```

would generate:

```ts
export type assignees = z.infer<typeof assignees>; // <-- ESLint error
export const assignees = z.array(...)
```

This PR adds a transformSchemaName option that allows to transform the
schema names to `PascalCase`.

That allows us to generate the correct schema names without having to
touch the API documentation yaml files.

This is the code that is generated with `transformSchemaName` set to
`pascalCase`.

```ts
export type Assignees = z.infer<typeof Assignees>;
export const Assignees = z.array(...)
```

For now `transformSchemaName` only supports `pascalCase` but it can be
extended in the future.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
(cherry picked from commit cb8b556)

# Conflicts:
#	src/platform/packages/shared/kbn-openapi-generator/src/parser/get_generation_context.ts
#	x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/attack_discovery/common_attributes.gen.ts
#	x-pack/solutions/security/packages/kbn-securitysolution-exceptions-common/api/import_exceptions/import_exceptions.gen.ts
#	x-pack/solutions/security/packages/kbn-securitysolution-exceptions-common/api/model/exception_list_common.gen.ts
#	x-pack/solutions/security/packages/kbn-securitysolution-lists-common/api/import_list_items/import_list_items.gen.ts
#	x-pack/solutions/security/plugins/security_solution/common/api/endpoint/actions/file_download/file_download.gen.ts
#	x-pack/solutions/security/plugins/security_solution/common/api/endpoint/actions/file_info/file_info.gen.ts
#	x-pack/solutions/security/plugins/security_solution/common/api/endpoint/actions/response_actions/run_script/run_script.gen.ts
#	x-pack/solutions/security/plugins/security_solution/common/api/endpoint/model/schema/common.gen.ts
#	x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/monitoring/monitoring_entity_source/monitoring_entity_source.gen.ts
@janmonschke janmonschke added the backport This PR is a backport of another PR label Feb 10, 2026
@janmonschke janmonschke enabled auto-merge (squash) February 10, 2026 10:02
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

API count

id before after diff
@kbn/openapi-generator 15 16 +1

History

@janmonschke janmonschke merged commit fb83aab into elastic:8.19 Feb 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants