-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution] Write additional metadata when generating types using kbn-openapi-generator
#174718
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
[Security Solution] Write additional metadata when generating types using kbn-openapi-generator
#174718
Changes from all commits
b94eca7
b881d0b
2258291
3c6f152
1b229e5
f906f7c
398a889
784350a
fba19b3
06a8a62
43ff211
8d50701
4122a12
747f909
2d1de1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,5 +7,7 @@ | |
| */ | ||
|
|
||
| export function getGeneratedFilePath(sourcePath: string) { | ||
| return sourcePath.replace(/\..+$/, '.gen.ts'); | ||
| // Remove any double extension like `.schema.yaml` or `.schema.yml` and replace with `.gen.ts` | ||
| const secondToLastDot = sourcePath.lastIndexOf('.', sourcePath.lastIndexOf('.') - 1); | ||
| return `${sourcePath.substring(0, secondToLastDot)}.gen.ts`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing the |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import type { OpenApiDocument } from '../openapi_types'; | ||
|
|
||
| export function getInfo(parsedSchema: OpenApiDocument) { | ||
| return parsedSchema.info; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| /* | ||
| * NOTICE: Do not edit this file manually. | ||
| * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. | ||
| * | ||
| * info: | ||
| * title: {{info.title}} | ||
| * version: {{info.version}} | ||
| */ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,13 @@ | |
|
|
||
| require('../../../../../src/setup_node_env'); | ||
| const { bundle } = require('@kbn/openapi-bundler'); | ||
| // eslint-disable-next-line import/no-nodejs-modules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a higher-level way to get eslint to treat these files the same as they were previously? It seems like there's a discrepancy between how it treats plugin code vs package code. Unless this code could be run in a browser, and
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question! 🙂 I noticed the same thing and wasn't sure so was just following what folks had done in the other scripts. I thought it was interesting that the
Whereas the Perhaps @jbudz can provide some insight here when he stops by for the operations review? |
||
| const { resolve } = require('path'); | ||
|
|
||
| const ELASTIC_ASSISTANT_ROOT = resolve(__dirname, '../..'); | ||
|
|
||
| bundle({ | ||
| rootDir: ELASTIC_ASSISTANT_ROOT, | ||
| sourceGlob: './server/schemas/**/*.schema.yaml', | ||
| sourceGlob: './impl/schemas/**/*.schema.yaml', | ||
| outputFilePath: './target/openapi/elastic_assistant.bundled.schema.yaml', | ||
| }); | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbudz, feedback was to move our schemas from plugin -> common package, so this that update.