Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kiota dose not generate code for Etsy OpenAPI. #1265

Closed
CoolIOT opened this issue Jun 11, 2023 · 7 comments
Closed

Kiota dose not generate code for Etsy OpenAPI. #1265

CoolIOT opened this issue Jun 11, 2023 · 7 comments
Labels
status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Milestone

Comments

@CoolIOT
Copy link

CoolIOT commented Jun 11, 2023

Kiota dose not generate code for Etsy OpenAPI.

To reproduce the bug.

  1. Copy the link https://www.etsy.com/openapi/generated/oas/3.0.0.json
  2. Go to Swagger Editor and click on File Then Import URL
  3. Paste the URL in the prompt and cick OK
  4. Save the generated yaml in a file Ex: Etsy.yaml
  5. Clone the repo and Execute kiota with this command line argument: generate -d (path/to/your/Etsy.yaml) -o generated -l CSharp

Got this Exception:

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the client: Value was either too large or too small for a Decimal.
      System.OverflowException: Value was either too large or too small for a Decimal.
         at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
         at System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_180(OpenApiSchema o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadSchema(ParseNode node)
         at Microsoft.OpenApi.Readers.ParseNodes.MapNode.<>c__DisplayClass6_0`1.<CreateMap>b__0(KeyValuePair`2 n)
         at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
         at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
         at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
         at Microsoft.OpenApi.Readers.ParseNodes.MapNode.CreateMap[T](Func`2 map)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_200(OpenApiSchema o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadSchema(ParseNode node)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_81(OpenApiMediaType o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadMediaType(ParseNode node)
         at Microsoft.OpenApi.Readers.ParseNodes.MapNode.<>c__DisplayClass6_0`1.<CreateMap>b__0(KeyValuePair`2 n)
         at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
         at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
         at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
         at Microsoft.OpenApi.Readers.ParseNodes.MapNode.CreateMap[T](Func`2 map)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_164(OpenApiRequestBody o, ParseNode n)         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadRequestBody(ParseNode node)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_112(OpenApiOperation o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadOperation(ParseNode node)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_149(OpenApiPathItem o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadPathItem(ParseNode node)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_160(OpenApiPaths o, String k, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadPaths(ParseNode node)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.<>c.<.cctor>b__102_25(OpenApiDocument o, ParseNode n)
         at Microsoft.OpenApi.Readers.ParseNodes.PropertyNode.ParseField[T](T parentInstance, IDictionary`2 fixedFields, IDictionary`2 patternFields)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.ParseMap[T](MapNode mapNode, T domainObject, FixedFieldMap`1 fixedFieldMap, PatternFieldMap`1 patternFieldMap)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3Deserializer.LoadOpenApi(RootNode rootNode)
         at Microsoft.OpenApi.Readers.V3.OpenApiV3VersionService.LoadDocument(RootNode rootNode)
         at Microsoft.OpenApi.Readers.ParsingContext.Parse(YamlDocument yamlDocument)
         at Microsoft.OpenApi.Readers.OpenApiYamlDocumentReader.ReadAsync(YamlDocument input, CancellationToken cancellationToken)
         at Microsoft.OpenApi.Readers.OpenApiTextReaderReader.ReadAsync(TextReader input, CancellationToken cancellationToken)
         at Kiota.Builder.KiotaBuilder.<>c__DisplayClass27_0.<<CreateOpenApiDocumentAsync>g__ReadAsync|0>d.MoveNext() in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 457
      --- End of stack trace from previous location ---
         at Kiota.Builder.KiotaBuilder.CreateOpenApiDocumentAsync(Stream input, Boolean generating, CancellationToken cancellationToken) in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 419
         at Kiota.Builder.KiotaBuilder.GetTreeNodeInternal(String inputPath, Boolean generating, Stopwatch sw, CancellationToken cancellationToken) in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 94
         at Kiota.Builder.KiotaBuilder.GetTreeNodeInternal(String inputPath, Boolean generating, Stopwatch sw, CancellationToken cancellationToken) in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 130
         at Kiota.Builder.KiotaBuilder.GenerateClientAsync(CancellationToken cancellationToken) in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 193
         at Kiota.Builder.KiotaBuilder.GenerateClientAsync(CancellationToken cancellationToken) in D:\_POC\Kiota\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 223
         at kiota.Handlers.KiotaGenerationCommandHandler.InvokeAsync(InvocationContext context) in D:\_POC\Kiota\kiota\src\kiota\Handlers\KiotaGenerationCommandHandler.cs:line 123

@baywet baywet transferred this issue from microsoft/kiota Jun 12, 2023
@baywet
Copy link
Member

baywet commented Jun 12, 2023

@CoolIOT
Thanks for reaching out and for reporting this. Transferred the issue to OpneAPI.net the library we're using to parse OpenAPI documents.

Just in case this is a conversion issue. Have you tried feeding the JSON document directly to Kiota? The parsing library supports both YAML and JSON.

@baywet baywet added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Jun 12, 2023
@CoolIOT
Copy link
Author

CoolIOT commented Jun 13, 2023

Yes, i've tried with the Json file and no result, get an exception

@MaggieKimani1
Copy link
Contributor

@baywet I'm assuming this will be resolved by this PR?

@baywet
Copy link
Member

baywet commented Jun 14, 2023

@MaggieKimani1 it's appear so since the document has a couple of very large maximum values (e.g. "Maximum": 1.79769313486e308 )

@darrelmiller
Copy link
Member

@baywet Why would we want to try and support a max value that is larger than the value that the type supports.

@darrelmiller darrelmiller modified the milestones: NET:2.0, 2.1 Mar 19, 2024
@baywet
Copy link
Member

baywet commented Mar 19, 2024

@darrelmiller From my readings of JSON schema it wasn't clear what range is supposed to be supported by parsing libraries
this simply says "number".
then this explicitly calls out validation of numbers is not bound to any specific precision or size, because of the JSON specification.
So while we can't support "anything" because of the constraints of the dotnet runtime, it made sense to expand the range of supported values in my mind.
Thoughts?

@CoolIOT
Copy link
Author

CoolIOT commented Mar 23, 2024

Issue Resolved: Successfully Generating C# Code with Kiota

I'm pleased to announce that I've successfully resolved the issue you were experiencing with generating C# code using Kiota. Here are the steps I took to resolve it:

  1. Updated Visual Studio 2022: I made sure to update Visual Studio 2022 to the latest version, ensuring compatibility and access to the latest features and bug fixes.

  2. Cloned Repo Kiota: I cloned the Kiota repository to ensure I had the most up-to-date version of the tool, which is crucial for resolving any potential issues related to outdated versions.

  3. Added Command Argument in launchSettings.json: I included the necessary command argument in the launchSettings.json file. Specifically, I added "commandLineArgs": "generate -d path\to\json\file.json -l CSharp --ll Trace". This ensures that the generation process is configured correctly with the appropriate settings.

  4. Built and Ran the Project: Finally, I built the project and ran it to confirm that the generation process was working as expected. By following these steps, I was able to successfully resolve the issue.

Thank you for your help :)

@CoolIOT CoolIOT closed this as completed Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
None yet
Development

No branches or pull requests

4 participants