Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions generator/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const managementGroupRootSchema = {
};
export const generatedSchemasTemplatePath = path.join(__dirname, 'resources/autogeneratedResources_template.json');

export const autorestCoreVersion = '3.0.6274';
export const azureresourceschemaVersion = '3.0.79';
export const autorestCoreVersion = '3.0.6306';
export const azureresourceschemaVersion = '3.0.86';

// paths in this list won't even appear in list-basepaths
export const blocklist = [
Expand Down
36 changes: 16 additions & 20 deletions generator/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ScopeType, AutogenlistConfig } from './models';
import { resetFile } from './git';
import { get, set, flatten, uniq, concat, Dictionary, groupBy, keys, difference, pickBy, flatMap, values, uniqBy } from 'lodash';

const autorestBinary = os.platform() === 'win32' ? 'autorest-beta.cmd' : 'autorest-beta';
const autorestBinary = os.platform() === 'win32' ? 'autorest.cmd' : 'autorest';
const apiVersionRegex = /^\d{4}-\d{2}-\d{2}(|-preview)$/;

export interface SchemaConfiguration {
Expand Down Expand Up @@ -50,31 +50,28 @@ export async function generateSchemas(readme: string, autogenlistConfig?: Autoge
await getApiVersionsByNamespace(readme),
(_, key) => !autogenlistConfig || lowerCaseEquals(key, autogenlistConfig.namespace));

const apiVersions = uniqBy(flatMap(values(apiVersionsByNamespace)), s => s.toLowerCase());
const namespaces = keys(apiVersionsByNamespace);

const schemaConfigs: SchemaConfiguration[] = [];
for (const apiVersion of apiVersions) {
const tmpFolder = path.join(os.tmpdir(), Math.random().toString(36).substr(2));
const tmpFolder = path.join(os.tmpdir(), Math.random().toString(36).substr(2));

try {
const generatedSchemas = await generateSchema(readme, tmpFolder, apiVersion);
try {
const generatedSchemas = await generateSchema(readme, tmpFolder);

for (const schemaPath of generatedSchemas) {
const namespace = path.basename(schemaPath.substring(0, schemaPath.lastIndexOf(path.extname(schemaPath))));
if (!lowerCaseContains(namespaces, namespace)) {
continue;
}
for (const schemaPath of generatedSchemas) {
const namespace = path.basename(schemaPath.substring(0, schemaPath.lastIndexOf(path.extname(schemaPath))));
if (!lowerCaseContains(namespaces, namespace)) {
continue;
}

const generatedSchemaConfig = await handleGeneratedSchema(readme, schemaPath, autogenlistConfig);
const generatedSchemaConfig = await handleGeneratedSchema(readme, schemaPath, autogenlistConfig);

schemaConfigs.push(generatedSchemaConfig);
}
}
finally {
await rmdirRecursive(tmpFolder);
schemaConfigs.push(generatedSchemaConfig);
}
}
finally {
await rmdirRecursive(tmpFolder);
}

return schemaConfigs;
}
Expand Down Expand Up @@ -134,14 +131,13 @@ async function execAutoRest(tmpFolder: string, params: string[]) {
return await findRecursive(tmpFolder, p => path.extname(p) === '.json');
}

async function generateSchema(readme: string, tmpFolder: string, apiVersion: string) {
async function generateSchema(readme: string, tmpFolder: string) {
const autoRestParams = [
`--version=${constants.autorestCoreVersion}`,
`--use=@autorest/azureresourceschema@${constants.azureresourceschemaVersion}`,
'--azureresourceschema',
`--output-folder=${tmpFolder}`,
`--tag=all-api-versions`,
`--api-version=${apiVersion}`,
`--multiapi`,
'--title=none',
'--pass-thru:subset-reducer',
readme,
Expand Down
24 changes: 12 additions & 12 deletions generator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"postprocessor": "ts-node cmd/postprocessor"
},
"devDependencies": {
"@autorest/autorest": "^3.0.6187",
"@autorest/azureresourceschema": "^3.0.79",
"@autorest/core": "^3.0.6257",
"autorest": "^3.0.6187",
"@autorest/azureresourceschema": "^3.0.86",
"@autorest/core": "^3.0.6306",
"@types/async": "^3.2.0",
"@types/lodash": "^4.14.149",
"@types/node": "^13.11.0",
Expand Down
4 changes: 2 additions & 2 deletions swagger_to_sdk_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"$schema": "https://openapistorageprod.blob.core.windows.net/sdkautomation/prod/schemas/swagger_to_sdk_config.schema.json",
"meta": {
"autorest_options": {
"use": "@autorest/[email protected].79",
"version": "3.0.6274",
"use": "@autorest/[email protected].86",
"version": "3.0.6306",
"azureresourceschema": "",
"multiapi": "",
"sdkrel:azureresourceschema-folder": ".",
Expand Down