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

bug: OpenAPI specification is invalid #6043

Closed
mostafa opened this issue Jun 17, 2024 · 1 comment · Fixed by #6092
Closed

bug: OpenAPI specification is invalid #6043

mostafa opened this issue Jun 17, 2024 · 1 comment · Fixed by #6092
Labels
bug Something isn't working Engineering

Comments

@mostafa
Copy link
Contributor

mostafa commented Jun 17, 2024

Describe the bug

When I use the openapi-generator-cli to generate a Go client from the API specification generated from the API at /api/swagger.json, I get the following validation errors and nothing is generated by the CLI:

docker run --rm \
    -v "./logto-client:/local" \
    openapitools/openapi-generator-cli generate \
    -i http://<ip-address>:3002/api/swagger.json \ # This is the IP address and port that is visible to the container
    -g go \
    --package-name logto \
    -p withGoMod=false \
    -p goImportAlias=logto \
    -o /local/
See validation errors
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
 | Error count: 18, Warning count: 0
Errors:
        -components.parameters.Parameter name factoryId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name resourceId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name applicationId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name ssoConnectorId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name connectorFactoryId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name organizationScopeId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name organizationInvitationId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name connectorId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name scopeId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name logId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name roleId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name keyId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name organizationId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name verificationId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name organizationRoleId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name userId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name hookId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
        -components.parameters.Parameter name domainId:root doesn't adhere to regular expression ^[a-zA-Z0-9\.\-_]+$
 
        at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:717)
        at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:744)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

If I use the suggested fix and use the --skip-validate-spec flag, I still see the errors, but the code will be generated. However, the generated code is invalid and doesn't compile. I initially thought that there is a problem with the Go extension of the openapi-generator-cli, but then I used the Swagger Editor and found out that the OpenAPI spec file is actually invalid.

Expected behavior

I'd like to see an OpenAPI specification document that complies with the OpenAPI 2/3 standards, so I can generate a client SDK from it.

How to reproduce?

Explained above using Docker, but one can also use the Java (JAR) file (install doc).

Context

Screenshots

image

@mostafa mostafa added the bug Something isn't working label Jun 17, 2024
@mostafa
Copy link
Contributor Author

mostafa commented Jun 22, 2024

Update:

I imported the OpenAPI file into Postman. Then I exported the Postman collection (saved it as a file) and converted it back to OpenAPI using the postman-to-openapi tool. The generated Go client from the converted OpenAPI spec doc is very messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Engineering
Development

Successfully merging a pull request may close this issue.

1 participant