docusign / OpenAPI-Specifications

The official Docusign REST APIs Swagger Specifications
MIT License
20 stars 15 forks source link

Cannot reliably generate API code for 2.1 #39

Open frahugo opened 3 years ago

frahugo commented 3 years ago

Hi,

Would you be willing to share the tools/commands you use to generate the API code for the different languages you have on the Developer Site?

I'm trying to generate the 2.1 API code and I'm running into many problems, both with OpenAPI generator and Swagger CodeGen. Eveything works fine with version 2.0 of the DocuSign specs.

Thanks

LarryKlugerDS commented 3 years ago

Hi @frahugo -- I've submitted DCM-5819 requesting publication of all tools/procedures needed to re-create our standard SDKs.

Meanwhile, can you provide more info on what is not working when you try to use the v2.1 Swagger file? Thanks, Larry

frahugo commented 3 years ago

Thanks @LarryKlugerDS

I use OpenAPI generator in Docker to generate Elixir code for the API:

docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/docusign/OpenAPI-Specifications/master/esignature.rest.swagger-v2.1.json -g elixir -o /local/out/elixir 

I end up with this error:

[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOfRange(Unknown Source)
    at java.base/java.lang.StringLatin1.newString(Unknown Source)
    at java.base/java.lang.StringBuilder.toString(Unknown Source)
    at com.fasterxml.jackson.core.util.TextBuffer.contentsAsString(TextBuffer.java:426)
    at com.fasterxml.jackson.core.io.SegmentedStringWriter.getAndClear(SegmentedStringWriter.java:83)
    at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1011)
    at io.swagger.v3.core.util.Json.pretty(Json.java:24)
    at org.openapitools.codegen.examples.ExampleGenerator.generate(ExampleGenerator.java:159)
    at org.openapitools.codegen.examples.ExampleGenerator.generateFromResponseSchema(ExampleGenerator.java:97)
    at org.openapitools.codegen.examples.ExampleGenerator.generateFromResponseSchema(ExampleGenerator.java:59)
    at org.openapitools.codegen.DefaultCodegen.handleMethodResponse(DefaultCodegen.java:3636)
    at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:3774)
    at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1113)
    at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1036)
    at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:561)
    at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:878)
    at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
    at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
    at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

If I generate it for python, I then get this error:

[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] ERROR o.o.codegen.DefaultCodegen - Error in generating `example` for the property response. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.
[main] ERROR o.o.codegen.DefaultCodegen - Error in generating `example` for the property response. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOfRange(Unknown Source)
    at java.base/java.lang.StringLatin1.newString(Unknown Source)
    at java.base/java.lang.StringBuilder.toString(Unknown Source)
    at com.fasterxml.jackson.core.util.TextBuffer.contentsAsString(TextBuffer.java:426)
    at com.fasterxml.jackson.core.io.SegmentedStringWriter.getAndClear(SegmentedStringWriter.java:83)
    at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1011)
    at io.swagger.v3.core.util.Json.pretty(Json.java:24)
    at org.openapitools.codegen.examples.ExampleGenerator.generate(ExampleGenerator.java:159)
    at org.openapitools.codegen.examples.ExampleGenerator.generateFromResponseSchema(ExampleGenerator.java:97)
    at org.openapitools.codegen.examples.ExampleGenerator.generateFromResponseSchema(ExampleGenerator.java:59)
    at org.openapitools.codegen.DefaultCodegen.handleMethodResponse(DefaultCodegen.java:3636)
    at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:3774)
    at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1113)
    at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1036)
    at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:561)
    at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:878)
    at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
    at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
    at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

Those commands for v2.0 work perfectly. This is quite strange.

LarryKlugerDS commented 3 years ago

Hmmm, I just compared the v2 and v2.1 Swagger files and I don't see any difference where they refer to the application/json content type. I suggest using debug mode in the openapi-generator-cli to find out more where the Swagger file is triggering the problem.

Or if that doesn't work, use binary search within the Swagger file to see if you can narrow down the reproducible error case.

Or run the generator under a debugger.

The v2.1 Swagger file is more than 50% bigger than v2. Maybe just leave out a lot of the API methods to make the file smaller and see if that helps. /Larry

frahugo commented 3 years ago

Thanks @LarryKlugerDS. I might spend some time on this next week. Although v2.0 is good enough for me right now.

igorwritingcode commented 3 years ago

Maybe it is because ConsumerDisclosure_GetConsumerDisclosureEnvelopeIdRecipientIdLangCode has multiple langCode?

lbilger commented 11 months ago

The issue is quite old but maybe it's still relevant for someone.

I saw a slightly different error message that might be related. Generating Java code using the OpenAPI Generator, it created an OpenAPI Spec YAML file of over 1GB. As the generator writes this to a String, the JVM complains that it doesn't like Strings over 1GB in size. My solution is to set the skipOperationExample flag to true.