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

Generating custom headers and query parameters in the clients' functions when generating clients from Open API definition. #5820

Closed
kalaiyarasiganeshalingam opened this issue Nov 24, 2023 · 2 comments

Comments

@kalaiyarasiganeshalingam
Copy link
Contributor

Description:
When making the request, the user can set the custom headers and queries in the request according to their purpose. But when we generate the client from openAPI spec which doesn't have a custom header or query definition, those generated clients' resource/remote function doesn't have these supports. So, We have to manually add those supports in all the client functions.

Describe your problem(s)
The OpenAPI definition [1] of msgraph-metadata Excel doesn't have a header parameter definition. However, The RestAPI doc says Excel APIs could be called in one of three modes[2]. Here, Users have to set the session id as a header parameter.

  • Persistent session
  • Non-persistent session
  • Sessionless

[1] https://github.com/microsoftgraph/msgraph-metadata/blob/master/openapi/v1.0/openapi.yaml
[2] https://learn.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0

Describe your solution(s)
In this situation, It could be easy If we have any ways to add the custom header and query parameters during the client generation.

@TharmiganK
Copy link
Contributor

TharmiganK commented May 8, 2024

The support for custom headers has been address via this client method change: #6475. This is sufficient for the above mentioned OpenAPI specification.

The support for custom queries are not yet addressed. If there such a requirement, we will allow it in the feature

Btw, the client generation with the above OpenAPI spec gives swagger parser error due to some parser limit:

May 08, 2024 9:46:10 AM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.v3.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content  (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
        at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:483)
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:422)
        at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:258)
        at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:172)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
        at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
        at org.yaml.snakeyaml.composer.Composer.composeSequenceNode(Composer.java:277)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:207)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
        at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:460)
        ... 16 more

May 08, 2024 9:46:10 AM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
SEVERE: Error parsing content
com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: The incoming YAML document exceeds the limit: 3145728 code points.
 at [Source: (StringReader); line: 84060, column: 46]
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:435)
        at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:100)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:25)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4867)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3219)
        at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:279)
        at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:172)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:172)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:429)
        ... 20 more

May 08, 2024 9:46:10 AM io.swagger.v3.parser.OpenAPIV3Parser readContents
WARNING: Exception while parsing:
com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: The incoming YAML document exceeds the limit: 3145728 code points.
 at [Source: (StringReader); line: 84060, column: 46]
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:435)
        at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:100)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:25)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4867)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3219)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:170)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:172)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:429)
        ... 18 more

May 08, 2024 9:46:11 AM io.swagger.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content  (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
        at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:435)
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:422)
        at io.swagger.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:248)
        at io.swagger.parser.SwaggerParser.deserializeYaml(SwaggerParser.java:124)
        at io.swagger.parser.SwaggerParser.readWithInfo(SwaggerParser.java:137)
        at io.swagger.v3.parser.converter.SwaggerConverter.readContents(SwaggerConverter.java:97)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
        at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
        at org.yaml.snakeyaml.composer.Composer.composeSequenceNode(Composer.java:277)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:207)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
        at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:414)
        ... 16 more

OpenAPI definition has errors: 
malformed or unreadable swagger supplied
attribute openapi is not of type `object`

@lnash94
Copy link
Member

lnash94 commented Jun 24, 2024

The support for custom headers has been address via this client method change: #6475. This is sufficient for the above mentioned OpenAPI specification.

The support for custom queries are not yet addressed. If there such a requirement, we will allow it in the feature

Btw, the client generation with the above OpenAPI spec gives swagger parser error due to some parser limit:

May 08, 2024 9:46:10 AM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.v3.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content  (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
        at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:483)
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:422)
        at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:258)
        at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:172)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
        at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
        at org.yaml.snakeyaml.composer.Composer.composeSequenceNode(Composer.java:277)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:207)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
        at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:460)
        ... 16 more

May 08, 2024 9:46:10 AM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
SEVERE: Error parsing content
com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: The incoming YAML document exceeds the limit: 3145728 code points.
 at [Source: (StringReader); line: 84060, column: 46]
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:435)
        at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:100)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:25)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4867)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3219)
        at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:279)
        at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:172)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:172)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:429)
        ... 20 more

May 08, 2024 9:46:10 AM io.swagger.v3.parser.OpenAPIV3Parser readContents
WARNING: Exception while parsing:
com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: The incoming YAML document exceeds the limit: 3145728 code points.
 at [Source: (StringReader); line: 84060, column: 46]
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:435)
        at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:609)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:100)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:25)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4867)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3219)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:170)
        at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:172)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:429)
        ... 18 more

May 08, 2024 9:46:11 AM io.swagger.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content  (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
        at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:435)
        at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
        at org.yaml.snakeyaml.Yaml.load(Yaml.java:422)
        at io.swagger.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:248)
        at io.swagger.parser.SwaggerParser.deserializeYaml(SwaggerParser.java:124)
        at io.swagger.parser.SwaggerParser.readWithInfo(SwaggerParser.java:137)
        at io.swagger.v3.parser.converter.SwaggerConverter.readContents(SwaggerConverter.java:97)
        at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:474)
        at io.ballerina.openapi.core.generators.common.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:745)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:367)
        at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:239)
        at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:407)
        at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:332)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:229)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockSequenceEntryKey.produce(ParserImpl.java:539)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
        at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
        at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
        at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
        at org.yaml.snakeyaml.composer.Composer.composeSequenceNode(Composer.java:277)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:207)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
        at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
        at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
        at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:414)
        ... 16 more

OpenAPI definition has errors: 
malformed or unreadable swagger supplied
attribute openapi is not of type `object`

The given Server error occurred due to the swagger parser issue and it can be solved by the below options

  1. Try to export Java env option -DmaxYamlCodePoints=99999999 and try to run the client command
  2. Try to use the JSON format of the given YAML to generate the client

This issue was closed with the support for custom headers has been address via this client method change: #6475. This is sufficient for the above mentioned OpenAPI specification.

@lnash94 lnash94 closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants