microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
3.02k stars 210 forks source link

kiota 1.9.0 behaves strangely when generating for try.gitea swagger.v1.json #3901

Closed Ibmurai closed 11 months ago

Ibmurai commented 11 months ago

When I run:

KIOTA_TUTORIAL_ENABLED=false kiota generate -l CSharp -d https://try.gitea.io/swagger.v1.json -o GiteaClient/ -c GiteaClient -n Mir.ClassLib.GiteaClient --ebc

For version 1.8.2 I get this:

warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/ - Multiple servers entries were found in the OpenAPI description. Only the first one will be used. The root URL can be set manually with the request adapter.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CommitUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CreateUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/EditUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Email/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Identity/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PayloadUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/original_position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/User/properties/email - The format email is not supported by Kiota and the string type will be used.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/git/commits/{sha}.{diffType} - The path signature '/repos/{}/{}/git/commits/{}' MUST be unique.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/pulls/{index}.{diffType} - The path signature '/repos/{}/{}/pulls/{}' MUST be unique.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property reason for model WatchInfo in API path \repos\{owner}\{repo}\subscription, the schema is invalid.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property content for model FileDeleteResponse in API path \repos\{owner}\{repo}\contents\{filepath}, the schema is invalid.
Generation completed successfully

For version 1.9.0 I get this:

warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/ - Multiple servers entries were found in the OpenAPI description. Only the first one will be used. The root URL can be set manually with the request adapter.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CommitUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CreateUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/EditUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Email/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Identity/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PayloadUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/original_position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/User/properties/email - The format email is not supported by Kiota and the string type will be used.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/git/commits/{sha}.{diffType} - The path signature '/repos/{}/{}/git/commits/{}' MUST be unique.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/pulls/{index}.{diffType} - The path signature '/repos/{}/{}/pulls/{}' MUST be unique.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property content for model FileDeleteResponse in API path \repos\{repos-id}\{Owner-id}\contents\{filepath}, the schema is invalid.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property reason for model WatchInfo in API path \repos\{repos-id}\{Owner-id}\subscription, the schema is invalid.
Generation completed successfully

The notable thing here is that 1.9.0 seems to invent path parameters {repos-id} and {Owner-id}, which are not defined in the swagger.v1.json

This gives problems with path parameters not mapping correctly to the URL template when using the generated library, since the template will reference these invented parameters, but the path parameters are set correctly (to owner and repo), so it will generate request strings like ...///... as opposed to .../some-owner/some-repo/...

baywet commented 11 months ago

Thanks for reporting this. It seems to have been introduced by #3760 as pointed out by @ttoth89 I'll be looking into this shortly.

baywet commented 11 months ago

Hi everyone, I've put together a fix for the issue at #3904 and we're discussing the possibility of a patch release so you don't have to wait the next minor release in January.

Ibmurai commented 11 months ago

Hi @ramsessanchez & @baywet,

I've just tried with 1.9.1 and I'm still getting {repos-id} and {Owner-id} in the warnings when generating from try.gitea:

KIOTA_TUTORIAL_ENABLED=false kiota generate -l CSharp -d https://try.gitea.io/swagger.v1.json -o GiteaClient/ -c GiteaClient -n Mir.ClassLib.GiteaClient --ebc
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/ - Multiple servers entries were found in the OpenAPI description. Only the first one will be used. The root URL can be set manually with the request adapter.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CommitUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/CreateUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/EditUserOption/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Email/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/Identity/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PayloadUser/properties/email - The format email is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/original_position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/PullReviewComment/properties/position - The format uint64 is not supported by Kiota for the type integer and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/components/schemas/User/properties/email - The format email is not supported by Kiota and the string type will be used.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/git/commits/{sha}.{diffType} - The path signature '/repos/{}/{}/git/commits/{}' MUST be unique.
fail: Kiota.Builder.KiotaBuilder[0]
      OpenAPI error: #/paths//repos/{owner}/{repo}/pulls/{index}.{diffType} - The path signature '/repos/{}/{}/pulls/{}' MUST be unique.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property content for model FileDeleteResponse in API path \repos\{repos-id}\{Owner-id}\contents\{filepath}, the schema is invalid.
warn: Kiota.Builder.KiotaBuilder[0]
      Omitted property reason for model WatchInfo in API path \repos\{repos-id}\{Owner-id}\subscription, the schema is invalid.
baywet commented 11 months ago

yes, the parameters will still be renamed to avoid conflicts, but the parameter serialization name is now also corrected in the generated code. That was the main problem for requests failing in some cases:

let us know if you still see mis-alignment in the generated code.