kiota icon indicating copy to clipboard operation
kiota copied to clipboard

generate command yields "error generating the SDK: Object reference not set to an instance of an object"

Open DavidBiesack opened this issue 3 years ago • 4 comments

Using kiota 0.6.0 on macos (installed via the Releases download here on GitHub):

curl -q https://gist.githubusercontent.com/DavidBiesack/cf30605f50d328aee36c9b5854859684/raw/9ca9d18ffe90128f2209a14b45f32930fdf3f2e5/banking-api-openapi-3.0.yaml > openapi.yaml
kiota generate --openapi openapi.yaml --language TypeScript --namespace-name Apiture.BankingClient --class-name BankingClient --clean-output --output ./gen/sdk/client --log-level Error

I get a cryptic error and the process fails:

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the SDK: Object reference not set to an instance of an object.

DavidBiesack avatar Oct 12 '22 17:10 DavidBiesack

Thanks for the bug report. Unfortunately, the OpenAPI.NET library that does the parsing for Kiota doesn't support internal $refs to something that is not a component. image You would need to point the schema to #/components/schemas/problemResponse to resolve the issue.

I'll open an issue on https://github.com/microsoft/openapi.net to try and get a more clear error reported for that scenario.

darrelmiller avatar Oct 16 '22 21:10 darrelmiller

alternatively, you can edit out the following to paths as they are the ones bringing the references the OpenAPI.net lib is not able to resolve:

  • /accounts/{accountId}/transactions
  • /accountBalances

baywet avatar Oct 17 '22 12:10 baywet

Thanks @darrelmiller . I'll adjust our tooling to simplify the $ref and keep schema references in #/components/schemas

Can kiota yield a better error message if the lib can't parse/resolve the input?

DavidBiesack avatar Oct 18 '22 20:10 DavidBiesack

right now the parsing lib just throws a null reference exception without any additional context. Assuming the OpenAPI.net lib threw something with more information, kiota could provide more actionable feedback to the user. @darrelmiller can you take that aspect into account when you log an issue over there please?

baywet avatar Oct 18 '22 21:10 baywet

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

ghost avatar Oct 23 '22 02:10 ghost