ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Handle error scenarios when invalid output path is given for OpenAPI CLI command #5116

Closed aneeshafedo closed 6 months ago

aneeshafedo commented 1 year ago

Description:

When an invalid output path is provided to the OpenAPI CLI command, the current behavior results in a crash accompanied by an Exception.

command: bal openapi -i service.bal -o openapi.yaml

[2023-09-05 09:09:26,702] SEVERE {b7a.log.crash} - Format specifier '%s' 
java.util.MissingFormatArgumentException: Format specifier '%s'
        at java.base/java.util.Formatter.format(Formatter.java:2672)
        at java.base/java.util.Formatter.format(Formatter.java:2609)
        at java.base/java.lang.String.format(String.java:2897)
        at io.ballerina.openapi.converter.diagnostic.ExceptionDiagnostic.<init>(ExceptionDiagnostic.java:38)
        at io.ballerina.openapi.cmd.OASContractGenerator.generateOAS3DefinitionsAllService(OASContractGenerator.java:137)
        at io.ballerina.openapi.cmd.OpenApiCmd.ballerinaToOpenApi(OpenApiCmd.java:245)
        at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:209)
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at io.ballerina.cli.launcher.Main.main(Main.java:56)

Please improve the tool to return a proper error message for the user without crashing the generation.

Related discord issue link : https://discord.com/channels/957996897782616114/1148464546550382602/1148464546550382602

Describe your problem(s)

Describe your solution(s)

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

dilanSachi commented 6 months ago

Apprantly this is now handled.

ERROR [:(1:1,1:1)] Failed to generate OpenAPI definition due to: /home/dilan/Documents/tempopenapigenfiles/balopenapi/openapi.yaml/v2_openapi.yaml (No such file or directory)