Azure / azure-resource-manager-schemas

Schemas used to author and validate Resource Manager Templates. These schemas power the intellisense and syntax completion in our ARM Tools VSCode extension, as well as the Export Template API
MIT License
609 stars 516 forks source link

Reenable Schema Autogeneration for Microsoft.Cdn #3021

Open t-bzhan opened 5 months ago

t-bzhan commented 5 months ago

Hi team, we have noticed that the Schema Autogeneration for Microsoft.Cdn has been temporally disabled in this commit: https://github.com/Azure/azure-resource-manager-schemas/commit/18ac72604a603b9150bca9c9c6c882ad94a33b73.

image

Can you provide more insight regarding to unexpected character error and provide some guidelines to repro it for better diagnosing?

t-bzhan commented 5 months ago

I have tried below steps and found no error:

The following steps are no longer necessary for onboarding, but listed here for reference:

  1. Follow the steps listed under Getting Started. The following commands assume you are running in the > generator directory.
  2. Run npm run list-basepaths to discover the specs repo path containing the swagger definitions.
  3. Run npm run generate-single -- --base-path {basePath} to generate schemas for them. Save the console output to file.
  4. Manually remove any existing references to your provider namespace (if any) from schemas/2019-04-01/deploymentTemplate.> json.
  5. Add the {basePath} to the autogenlist array in autogenlist.ts.
  6. Commit all the changed files, and submit a PR to this repo with title "Onboarding {provider} for autogeneration". Include > the full output saved in step 2 as a comment.
  7. Ensure all CI tests pass, and ask the team to review the PR (including tool output) to ensure that all expected resources > have been detected and generated as expected.

This is the output for : npm run generate-single -- --base-path cdn/resource-manager

D:\github\azure-resource-manager-schemas\generator (main -> origin) λ npm run generate-single -- --base-path cdn/resource-manager

template-schema-generator@1.0.0 generate-single ts-node cmd/generatesingle --base-path cdn/resource-manager

[C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git fsck [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git reset -q . [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git checkout -q -- . [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git clean -q -fd [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git gc [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git fetch -q [C:\Users\bzhan\AppData\Local\Temp\schm_azspc] executing: git checkout -q origin/main Using autogenlist config: { "basePath": "cdn/resource-manager", "namespace": "Microsoft.Cdn" } [D:\github\azure-resource-manager-schemas\generator] executing: D:\github\azure-resource-manager-schemas\generator/node_modules/.bin/autorest.cmd --version=3.0.6374 --use=@autorest/azureresourceschema@3.0.109 --azureresourceschema --output-folder=C:\Users\bzhan\AppData\Local\Temp\i4f4gnwts2 --multiapi --pass-thru:subset-reducer --pass-thru:schema-validator-swagger C:\Users\bzhan\AppData\Local\Temp\schm_azspc\specification\cdn\resource-manager\readme.md AutoRest code generation utility [cli version: 3.6.3; node: v20.11.1] (C) 2018 Microsoft Corporation. https://aka.ms/autorest info | AutoRest core version selected from configuration: 3.0.6374.

There is a new version of AutoRest available (3.7.1).

You can install the newer version with with npm install -g autorest@latest

Loading AutoRest core 'C:\Users\bzhan.autorest\@autorestcore@3.0.6374\nodemodules\@autorest\core\dist' (3.0.6374) Installing AutoRest extension '@autorest/azureresourceschema' (3.0.109) Installed AutoRest extension '@autorest/azureresourceschema' (3.0.109->3.0.109) [5.79 s] Generation Complete

Xynoclafe commented 5 months ago

I unfortunately don't have access to the logs anymore to provide more details regarding the error we found during generation. I will try rebuilding the schema for Microsoft.cdn today. If it passes, I'll re-enable it for autogeneration and it should go in next week. I will provide more details about the error if it fails again

Xynoclafe commented 5 months ago

@t-bzhan We found a bug when the generate-single command is run in windows, which is why it exited with no errors. You may have noticed that no schemas were generated when you ran the command. We are in the process of checking in a fix for it.

That said, we still encounter an error while generating schemas for Microsoft.cdn, due to some issue with the swagger file. This was for 2024-02-01 API version, though the error may be present in older specs as well. This is the error that we get:

FATAL: Error parsing swagger file. Unexpected character encountered while parsing value: [. Path 'components.schemas.schemas:148.default', line 1, position 88418.

We can re-enable it for autogeneration once the swagger error has been fixed.