Autorest: Unable to generate API SDK for Azure Time Series Insights

Created on 5 Apr 2021  ·  9Comments  ·  Source: Azure/autorest

Before asking the question:

  • [x] have you checked the documentation in the [docs folder(https://github.com/Azure/autorest/tree/master/docs) and couldn't find the information there
  • [x] have you checked existing issues for a similar question?

I'm trying to follow the myriad of doc fragments to generate this API, and it is frustrating. Is there any nuget already packaged for the different versions?

❯ autorest .\azure-rest-api-specs\specification\timeseriesinsights\data-plane\readme.md --csharp-sdks-folder=.\Generated --csharp --verbose --latest --azure-validator --semantic-validator

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.4; node: v15.12.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\iskan\AppData\Roaming\npm\node_modules\@autorest\core\dist' (3.2.4)
VERBOSE [0.7 s]: > Initial configuration file 'file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/readme.md'
VERBOSE [0.7 s]: > Including configuration file 'file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/readme.md'
VERBOSE [0.73 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/default-configuration.md'
VERBOSE [0.75 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/inspect.md'
VERBOSE [0.76 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/directives.md'
VERBOSE [0.78 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/pipeline.md'
VERBOSE [0.81 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/loader-openapi.md'
VERBOSE [0.83 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/miscellaneous.md'
VERBOSE [0.85 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/patches.md'
VERBOSE [0.88 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-powershell.md'
VERBOSE [0.91 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
VERBOSE [0.93 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-csharp.md'
VERBOSE [0.95 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-go.md'
VERBOSE [0.98 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-java.md'
VERBOSE [1 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-nodejs.md'
VERBOSE [1.02 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-php.md'
VERBOSE [1.04 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-python.md'
VERBOSE [1.06 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-ruby.md'
VERBOSE [1.09 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-typescript.md'
VERBOSE [1.11 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-validators.md'
VERBOSE [1.14 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-az.md'
VERBOSE [1.16 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-terraform.md'
VERBOSE [1.19 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-azure-functions.md'
VERBOSE [1.22 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/graphs.md'
VERBOSE [1.25 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/help-configuration.md'
azure:@azure-tools/extension:error Error resolving package C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\core [OperationalError: ENOENT: no such file or directory, open 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\core\package.json'] {
  cause: [Error: ENOENT: no such file or directory, open 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\core\package.json'] {
    errno: -4058,
    code: 'ENOENT',
    syscall: 'open',
    path: 'C:\\Users\\iskan\\.autorest\\@[email protected]\\node_modules\\@autorest\\core\\package.json'
  },
  isOperational: true,
  errno: -4058,
  code: 'ENOPACKAGEJSON',
  syscall: 'open',
  path: 'C:\\Users\\iskan\\.autorest\\@[email protected]\\node_modules\\@autorest\\core\\package.json'
}
azure:@azure-tools/extension:error Error resolving package C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\csharp [OperationalError: ENOENT: no such file or directory, open 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\csharp\package.json'] {
  cause: [Error: ENOENT: no such file or directory, open 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\csharp\package.json'] {
    errno: -4058,
    code: 'ENOENT',
    syscall: 'open',
    path: 'C:\\Users\\iskan\\.autorest\\@[email protected]\\node_modules\\@autorest\\csharp\\package.json'
  },
  isOperational: true,
  errno: -4058,
  code: 'ENOPACKAGEJSON',
  syscall: 'open',
  path: 'C:\\Users\\iskan\\.autorest\\@[email protected]\\node_modules\\@autorest\\csharp\\package.json'
}
INFORMATION: > Installing AutoRest extension '@autorest/csharp' (latest)
INFORMATION: > Installed AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20210402.1)
FATAL: Failed to install extension '@autorest/csharp' (latest)
  Error: ENOENT: no such file or directory, scandir 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\csharp'

I just don't know how to move on from here
I'd appreciate any suggestions

question

All 9 comments

Hi @iskandersierra seems like there might have been an issue installing the extensions. You can first try running autorest --reset to fix this particular issue. However it seems like 2 extension failed to load, are you behing a proxy? Does running npm install @autorest/csharp somewhere on your system works fine?

Hi @timotheeguerin, I just tried to reset and reinstall the csharp extension

❯ autorest --reset

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.4; node: v15.12.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Clearing 16 autorest temp data folders...


Cleared the AutoRest extension folder.
On the next run, extensions will be reacquired from the repository.
❯ npm install -g @autorest/csharp

changed 1 package, and audited 2 packages in 7s

found 0 vulnerabilities

With no errors, so I'm assuming this is a clean setup.

However the command to generate an SDK for azure-rest-api-specs is not working:

❯ autorest .\azure-rest-api-specs\specification\timeseriesinsights\data-plane\readme.md --csharp-sdks-folder=.\Generated --csharp --verbose --latest --azure-validator --semantic-validator

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.4; node: v15.12.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\iskan\AppData\Roaming\npm\node_modules\@autorest\core\dist' (3.2.4)
VERBOSE [0.69 s]: > Initial configuration file 'file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/readme.md'
VERBOSE [0.69 s]: > Including configuration file 'file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/readme.md'
VERBOSE [0.73 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/default-configuration.md'
VERBOSE [0.75 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/inspect.md'
VERBOSE [0.76 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/directives.md'
VERBOSE [0.78 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/pipeline.md'
VERBOSE [0.8 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/loader-openapi.md'
VERBOSE [0.82 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/miscellaneous.md'
VERBOSE [0.83 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/patches.md'
VERBOSE [0.86 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-powershell.md'
VERBOSE [0.88 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-azureresourceschema.md'
VERBOSE [0.9 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-csharp.md'
VERBOSE [0.92 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-go.md'
VERBOSE [0.94 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-java.md'
VERBOSE [0.96 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-nodejs.md'
VERBOSE [0.97 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-php.md'
VERBOSE [0.99 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-python.md'
VERBOSE [1.01 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-ruby.md'
VERBOSE [1.03 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-typescript.md'
VERBOSE [1.05 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-validators.md'
VERBOSE [1.08 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-az.md'
VERBOSE [1.1 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-terraform.md'
VERBOSE [1.12 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/plugin-azure-functions.md'
VERBOSE [1.15 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/graphs.md'
VERBOSE [1.17 s]: > Including configuration file 'file:///C:/Users/iskan/AppData/Roaming/npm/node_modules/@autorest/core/dist/resources/help-configuration.md'
INFORMATION: > Installing AutoRest extension '@autorest/csharp' (latest)
VERBOSE [3.87 s]: Installing @autorest/csharp, 3.0.0-beta.20210405.2
VERBOSE [8.51 s]: Package Install completed @autorest/csharp, 3.0.0-beta.20210405.2
INFORMATION: > Installed AutoRest extension '@autorest/csharp' (latest->3.0.0-beta.20210405.2)
FATAL: Failed to install extension '@autorest/csharp' (latest)
  Error: ENOENT: no such file or directory, scandir 'C:\Users\iskan\.autorest\@[email protected]\node_modules\@autorest\csharp'

If I list folder C:\Users\iskan\.autorest\@[email protected]\ it is empty, not even node_modules. But the package is installed globally.

❯ npm list -g @autorest
C:\Users\iskan\AppData\Roaming\npm
+-- @autorest/[email protected]
+-- @autorest/[email protected]
+-- [email protected]
...

This is the first time using AutoRest, so I don't know where to start looking to fix this issue.

If someone can reproduce the instructions to generate the C# client for this folder, as an example, it would be great:

Time Series Insights Data Plane latest version

Do you happen to have a package.json file in one of the parent folder of C:\Users\iskan\.autorest\@[email protected]\ ?

Yes I do, at C:\Users\iskan, but it was created by the tool just today:

{
  "dependencies": {
    "@autorest/core": "https://registry.npmjs.org/@autorest/core/-/core-3.2.4.tgz",
    "@autorest/csharp": "https://registry.npmjs.org/@autorest/csharp/-/csharp-3.0.0-beta.20210405.2.tgz"
  }
}

hhm weird, but maybe that is the reason for the latest failure not the original one. That file shouldn't be there and would be the reason for that issue(does C:\Users\iskan happen to have a node_modules folder with @autorest/csharp in there?)

If you remove that file, do autorest --reset again does it still fail?

Yes!, that did the trick to unlock the next issue :). However ...

... bunch of verbose messages
WARNING (PreCheck/SchemaMissingType): The schema 'Availability-distribution' with an undefined type and additionalProperties is a bit ambigious. This has been auto-corrected to 'type:object'

WARNING (PreCheck/SchemaMissingType): The schema 'TimeSeriesType-variables' with an undefined type and additionalProperties is a bit ambigious. This has been auto-corrected to 'type:object'

WARNING (PreCheck/CheckDuplicateSchemas): Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.
VERBOSE [44.46 s]:   ModelerFour/api-version-mode:client
VERBOSE [44.46 s]:   ModelerFour/api-version-parameter:constant
VERBOSE [44.46 s]:   ModelerFour/use-model-namespace:false

WARNING (Modeler/MissingType): The schema 'TimeSeriesIdItem' has no type or format information whatsoever. Location:
   file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json#/components/schemas/TimeSeriesIdItem

WARNING (Modeler/MissingType): The schema 'PropertyValues-valuesItem' has no type or format information whatsoever. Location:
   file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json#/components/schemas/PropertyValues-valuesItem

WARNING (Modeler/MissingType): The schema 'components·8jzr1a·schemas·timeseriesinstance·properties·instancefields·additionalproperties' has no type or format information whatsoever. Location:
   file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json#/components/schemas/components·8jzr1a·schemas·timeseriesinstance·properties·instancefields·additionalproperties

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5464:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5494:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5516:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5603:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5639:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5657:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5818:4

ERROR (AvoidAnonymousTypes/R2026/SDKViolation): Inline/anonymous models must not be used, instead define a schema with a model name in the "definitions" section and refer to it. This allows operations to share the models.
    - file:///C:/Users/iskan/source/repos/GitHub/azure-rest-api-specs/specification/timeseriesinsights/data-plane/Microsoft.TimeSeriesInsights/stable/2020-07-31/timeseriesinsights.json:5954:4
WARNING: output-folder path should be an absolute path
[50.91 s] Generation Complete

It says Generation Complete but listing folder Generated gives empty folder.

Are those errors indicating that the json itself contains invalid specs and autorest will not generate until fixed?

The errors start happening after line 5464, but the file have only 2517 lines

I looked through all schemas in the file, and all have the $ref attribute.

... Ok!, I removed the --azure-validator and there are no errors, but the code is not generated on the given folder

Done!

After all your suggestions (mainly removing the package.json file above %USERPROFILE%/.autorest), I followed instructions here and it worked as expected:

❯ autorest

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.1.4; node: v15.12.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\iskan\AppData\Roaming\npm\node_modules\@autorest\core\dist' (3.2.4)
[3.79 s] Generation Complete
❯ ls .\generated\

    Directory: C:\Users\iskan\source\repos\GitHub\azure-rest-api-specs\specification\timeseriesinsights\data-plane\generated

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            4/5/2021 11:32 PM                Models
-a---            4/5/2021 11:45 PM          10652 ModelSettingsRestClient.cs
-a---            4/5/2021 11:45 PM          19096 QueryRestClient.cs
-a---            4/5/2021 11:45 PM          11548 TimeSeriesHierarchiesRestClient.cs
-a---            4/5/2021 11:45 PM          22047 TimeSeriesInstancesRestClient.cs
-a---            4/5/2021 11:45 PM          11318 TimeSeriesTypesRestClient.cs

So we can close this issue. Thanks a lot for your time!

Sweet, yeah --azure-validator is mosty for Arm libraries and this is a data-plane so they wouldn't necessarily be following the same rules

Was this page helpful?
0 / 5 - 0 ratings