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] operationId generated by odata makes generator fail #17108

Closed
Supernectar opened this issue Nov 16, 2023 · 0 comments · Fixed by #17125
Closed

[BUG] operationId generated by odata makes generator fail #17108

Supernectar opened this issue Nov 16, 2023 · 0 comments · Fixed by #17125

Comments

@Supernectar
Copy link

Supernectar commented Nov 16, 2023

Description

Using the openapi-generator-cli command over a swagger.json file generated by an asp.net project that uses OData doesn't work.

When using OData in an asp.net project, the operationId field in the swagger.json file is autogenerated and sometimes includes a '$' symbol. This causes an exception to be thrown in the console.

Manually removing the '$' symbol gets rid of the exception but I want to be able to keep it programmatic without having to manually modify the file.

Steps to reproduce

Run the following command openapi-generator-cli generate -g jmeter -i swagger.json
swagger.json

{
    "openapi": "3.0.1",
    "info": {
        "title": "WebApplication1",
        "version": "1.0"
    },
    "paths": {
        "/Customers/$count": {
            "get": {
                "tags": [
                    "Customers"
                ],
                "operationId": "Customers/$count",
                "responses": {
                    "200": {
                        "description": "Success"
                    }
                }
            }
        }
    }
}

The following exception is thrown in the console:

[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: jmeter (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'jmeter' is considered stable.
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
  Tag: class Tag {
    name: Customers
    description: null
    externalDocs: null
}
  Operation: Customers/$count
  Resource: get /Customers/$count
  Schemas: {}
  Exception: Illegal group reference: group index is missing
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1269)
	at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1160)
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:609)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:994)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:519)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.IllegalArgumentException: Illegal group reference: group index is missing
	at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1030)
	at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:998)
	at java.base/java.util.regex.Matcher.replaceFirst(Matcher.java:1408)
	at org.openapitools.codegen.utils.StringUtils.lambda$camelize$1(StringUtils.java:141)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2406)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1908)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2404)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2387)
	at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108)
	at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62)
	at org.openapitools.codegen.utils.StringUtils.camelize(StringUtils.java:135)
	at org.openapitools.codegen.utils.StringUtils.camelize(StringUtils.java:115)
	at org.openapitools.codegen.DefaultCodegen.addOperationToGroup(DefaultCodegen.java:5701)
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1239)
	... 6 more

I expect the command to run properly and a jmeter file to be generated properly.

openapi-generator version

7.1.0 - installed via npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant