Skip to content

Commit a5c12f2

Browse files
authored
Fix release type swagger generation script (#265)
* Fix release type swagger generation script * Remove typeload build from pipeline
1 parent 4c0f0cf commit a5c12f2

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

pipelines/ci-build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737

3838
- template: ./common-templates/security-pre-checks.yml
3939

40-
- template: ./common-templates/common-steps.yml
41-
parameters:
42-
Official: false
40+
- template: ./common-templates/generate-types.yml
4341

4442
- template: ./common-templates/security-post-checks.yml

pipelines/common-variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variables:
77
ArtifactName: "GeneratedFiles"
88
ProductBinPath: '$(Build.SourcesDirectory)/src/Microsoft.Graph.Bicep.Types/bin/$(BuildConfiguration)'
99
BuildSolution: '$(Build.SourcesDirectory)/Microsoft.Graph.Bicep.Types.sln'
10-
SwaggerFilePath: '$(Build.SourcesDirectory)/swagger/specification/microsoftgraph/resource-manager/microsoftgraph/preview'
10+
SwaggerFilePath: '$(Build.SourcesDirectory)/swagger/specification/microsoftgraph/resource-manager/microsoftgraph'
1111
AutoRestWorkingDir: "$(Build.SourcesDirectory)/src/autorest.bicep"
1212
BicepTypesWorkingDir: "$(Build.SourcesDirectory)/bicep-types/src/bicep-types"
1313
GeneratorWorkingdir: "$(Build.SourcesDirectory)/src/generator"

scripts/UpdateGeneratedTypes.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Write-Host "Autorest successfully built"
3838
Write-Host "Generating Swagger spec"
3939
npm ci --prefix $SwaggerGenerationPrefix
4040
npm audit fix
41-
npm run --prefix $SwaggerGenerationPrefix start "--" --output=C:\Git\msgraph-bicep-types\swagger\specification\microsoftgraph\resource-manager\microsoftgraph\preview
41+
npm run --prefix $SwaggerGenerationPrefix start "--" --output=C:\Git\msgraph-bicep-types\swagger\specification\microsoftgraph\resource-manager\microsoftgraph
4242
Write-Host "Swagger spec successfully generated"
4343

4444
# Generate Bicep types

src/swagger-generation/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async function parse(config: Config): Promise<[Metadata, Swagger]> {
4545

4646
function writeSwaggerFile(swagger: Swagger, apiVersion: string, extensionVersion: string) {
4747
const swaggerJson: string = JSON.stringify(swagger, null, 2);
48-
const fullOutputPath = `${outputPath}/${apiVersion}`;
48+
const releaseType: string = getReleaseTypeFromExtensionVersion(extensionVersion);
49+
const fullOutputPath = `${outputPath}/${releaseType}/${apiVersion}`;
4950

5051
if (outputPath !== 'output') {
5152
if (!fs.existsSync(fullOutputPath)) {
@@ -77,11 +78,11 @@ function writeSwaggerReadMeFile(apiExtensionVersions: { [key in ApiVersion]: str
7778
let betaVersionsContent = '';
7879
let v1VersionsContent = '';
7980
for (const version of apiExtensionVersions[ApiVersion.Beta]) {
80-
const releaseType = version.endsWith('preview') ? 'preview' : 'official';
81+
const releaseType = getReleaseTypeFromExtensionVersion(version);
8182
betaVersionsContent += `\n - microsoftgraph/${releaseType}/beta/${version}.json`;
8283
}
8384
for (const version of apiExtensionVersions[ApiVersion.V1_0]) {
84-
const releaseType = version.endsWith('preview') ? 'preview' : 'official';
85+
const releaseType = getReleaseTypeFromExtensionVersion(version);
8586
v1VersionsContent += `\n - microsoftgraph/${releaseType}/v1.0/${version}.json`;
8687
}
8788
let readMeContent = `# MicrosoftGraph
@@ -130,6 +131,10 @@ input-file: ${v1VersionsContent}
130131
});
131132
}
132133

134+
function getReleaseTypeFromExtensionVersion(extensionVersion: string): 'preview' | 'official' {
135+
return extensionVersion.endsWith('preview') ? 'preview' : 'official';
136+
}
137+
133138
async function main() {
134139
let extensionVersionMetadata: ExtensionVersionMetadata = require('../output/metadata.json');
135140
let metadata: Metadata = {};

0 commit comments

Comments
 (0)