-
Notifications
You must be signed in to change notification settings - Fork 27
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
Generate schemas using autorest.bicep #1740
Conversation
88d7d05
to
50d056b
Compare
Codecov Report
@@ Coverage Diff @@
## main #1740 +/- ##
=======================================
Coverage 95.00% 95.00%
=======================================
Files 2 2
Lines 20 20
=======================================
Hits 19 19
Misses 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. |
e4caeb0
to
9082b99
Compare
0f5bf5f
to
4728bcd
Compare
ea43986
to
2970e42
Compare
2970e42
to
4f20acb
Compare
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { AutorestExtensionHost, Channel } from '@autorest/extension-base'; |
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.
FYI a lot of the quirks in this file are due to trying to maintain bug-for-bug compatibility with the current generator (https://github.com/Azure/autorest.azureresourceschema). I initially worked on this by comparing the output and iterating to match it.
@@ -189,7 +192,7 @@ ${yaml.dump({ 'input-file': filesByTag[tag] }, { lineWidth: 1000})} | |||
await writeFile(bicepReadmePath, generatedContent); | |||
} | |||
|
|||
async function generateSchema(logger: ILogger, readme: string, outputBaseDir: string, logLevel: string, waitForDebugger: boolean) { | |||
async function runAutorest(logger: ILogger, readme: string, outputBaseDir: string, logLevel: string, waitForDebugger: boolean) { |
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.
Would users rely on this file to generate schemas? Unlike with the version in src/autorest.bicep/test/integration/utils.ts
, I don't see a way to run autorest with the flag --arm-schema=true
via this command.
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.
To start off with, I'm planning to add this as a git submodule to https://github.com/Azure/azure-resource-manager-schemas, and running it directly from the orchestration scripts there.
It has its own schemas folder structure and fairly complex generation script that I'm not ready to change yet. If I'm able to clean that up sufficiently, I might try and migrate it into this repo.
}; | ||
} | ||
|
||
function throwIfNull<TSchema extends Schema>(putSchema: TSchema | undefined) { |
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.
is TSchema | undefined
different from TSchema?
?
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.
In terms of how the function is processed, I don't think so. It does make the argument optional, which is a bit odd - e.g. you could call throwIfNull()
https://github.com/Azure/azure-resource-manager-schemas has a dependency on a very old and unsupported Autorest plugin (source repo here), and to be able to keep supporting this process, it would make sense to try and upgrade to a more recent version.
Rather than forking this repo and creating a new TS-based plugin, it feels better to try and share the code. This PR adds an optional flag
--arm-schema
that'll generate JSON instead of Bicep if used.