Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@kbn/openapi-generator: Support object keys which need to be surrounded by quotes #172049

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Nov 28, 2023

Summary

❓ Are there tests for @kbn/openapi-generator? I couldn't find them ❓

Our team had a @timestamp field in an API response, this caused the zod schema to break because the key was not being escaped in the object e.g:

export const AssetCriticalityRecord =       CreateAssetCriticalityRecord.and(z.object({
      // ❌ invalid JS
      @timestamp: z.string().datetime(),
  }));

With the fix, the @timestamp key is surrounded by quotes.

export const AssetCriticalityRecord =       CreateAssetCriticalityRecord.and(z.object({
     // ✅ 
      '@timestamp': z.string().datetime(),
  }));

@hop-dev hop-dev requested a review from a team as a code owner November 28, 2023 11:23
@hop-dev hop-dev requested a review from jpdjere November 28, 2023 11:23
@hop-dev
Copy link
Contributor Author

hop-dev commented Nov 28, 2023

@elasticmachine merge upstream

@hop-dev hop-dev self-assigned this Nov 28, 2023
@hop-dev hop-dev added the release_note:skip Skip the PR/issue when compiling release notes label Nov 28, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @hop-dev

Copy link
Contributor

@jpdjere jpdjere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@hop-dev hop-dev merged commit bf5f8cb into elastic:main Nov 29, 2023
29 checks passed
@kibanamachine kibanamachine added v8.12.0 backport:skip This commit does not require backporting labels Nov 29, 2023
@hop-dev hop-dev deleted the api-docgen-special-fields branch November 29, 2023 11:44
@banderror
Copy link
Contributor

@hop-dev Thank you for the fix!

❓ Are there tests for @kbn/openapi-generator? I couldn't find them ❓

At this point we don't have any tests, unfortunately. Our code-generated schemas have been an excuse for that because we use them in our API endpoints, which are themselves covered with tests pretty well. We may revisit this in a few months, but currently, our team doesn't have the capacity to work on test coverage for the codegen package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants