azure-sdk-for-go icon indicating copy to clipboard operation
azure-sdk-for-go copied to clipboard

Can't generate from autorest.md file

Open jhendrixMSFT opened this issue 3 years ago • 3 comments

D:\git\Azure\azure-sdk-for-go\sdk\resourcemanager\compute\armcompute> autorest --use=d:\git\Azure\autorest.go\src .\autorest.md

error | PreCheck/DuplicateSchema | Duplicate Schema named 'PurchasePlan' (1 differences):

  • properties.promotionCode: => {"$ref":"#/components/schemas/schemas:1405","description":"The Offer Promotion Code."}; This error can be temporarily avoided by using the 'modelerfour.lenient-model-deduplication' setting. NOTE: This setting will be removed in a future version of @autorest/modelerfour; schemas should be updated to fix this issue sooner than that.

Lenient model deduplication is missing.

Add setting to autorest.md.

modelerfour:
  lenient-model-deduplication: true

Generation works, but the output path is incorrect, it's under generated/ directory.

Untracked files: (use "git add ..." to include in what will be committed) generated/

no changes added to commit (use "git add" and/or "git commit -a") PS D:\git\Azure\azure-sdk-for-go\sdk\resourcemanager\compute\armcompute>

Purpose of autorest.md files in the SDK repo is to make SDK rebuilds reproducible. I should be able to execute autorest ./autorest.md and get the exact same output that's in source control.

jhendrixMSFT avatar Oct 10 '22 17:10 jhendrixMSFT

You may need to add --go --track2 --output-folder=. to use autorest to directly generate the SDK. For mgmt. generation, we always use go generate to do the generation. But if it is a required to use autorest.md directly, I could add the flag to it.

tadelesh avatar Oct 11 '22 06:10 tadelesh

I see, I missed the build.go file, that does help. Is there a way to specify a different version of the code generator?

jhendrixMSFT avatar Oct 11 '22 16:10 jhendrixMSFT

I see, I missed the build.go file, that does help. Is there a way to specify a different version of the code generator?

You can add -goExtension d:\git\Azure\autorest.go\src flag to the cmd in build.go. For example: //go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -goExtension d:\git\Azure\autorest.go\src resourcemanager/compute/armcompute.

tadelesh avatar Oct 12 '22 03:10 tadelesh