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

NoSuchMethodError in io.javalin.openapi.plugin.DefinitionConfiguration #233

Open
mikera opened this issue Nov 5, 2024 · 0 comments
Open

Comments

@mikera
Copy link

mikera commented Nov 5, 2024

I recently encountered the following exception (Javalin 6.3.0), which occurs when trying to access the swagger UI:

[JettyServerThreadPool-165] ERROR io.javalin.Javalin - Fatal error occurred while servicing http-request
java.lang.NoSuchMethodError: 'io.javalin.openapi.plugin.DefinitionConfiguration io.javalin.openapi.plugin.DefinitionConfiguration.withInfo(java.util.function.Consumer)'
	at convex.restapi.RESTServer.lambda$8(RESTServer.java:135)
	at io.javalin.openapi.plugin.OpenApiPlugin$createDocumentation$1.invoke(OpenApiPlugin.kt:36)
	at io.javalin.openapi.plugin.OpenApiPlugin$createDocumentation$1.invoke(OpenApiPlugin.kt:25)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)

I would expect this not to throw such an exception, because the code compiles fine and the target method apparently exists.

Calling code looks like:

	protected void addOpenApiPlugins(JavalinConfig config) {
		String docsPath="openapi-plugin/openapi-default.json";
		
		config.registerPlugin(new OpenApiPlugin(pluginConfig -> {
                    pluginConfig
                    .withDocumentationPath(docsPath)
                    .withDefinitionConfiguration((version, definition) -> {
                    	DefinitionConfiguration def=definition;
                        def=def.withInfo((Consumer <OpenApiInfo> )info -> {
					info.setTitle("Convex REST API");
					info.setVersion("0.7.0");
                        });
                    });
		}));

		config.registerPlugin(new SwaggerPlugin(swaggerConfiguration->{
			swaggerConfiguration.setDocumentationPath(docsPath);
		}));
		config.registerPlugin(new ReDocPlugin(reDocConfiguration -> {
	        reDocConfiguration.setDocumentationPath(docsPath);
	    }));
		
		for (JsonSchemaResource generatedJsonSchema : new JsonSchemaLoader().loadGeneratedSchemes()) {
	        System.out.println(generatedJsonSchema.getName());
	    }
	}

This looks like a bug, though I could be doing something wrong?

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

No branches or pull requests

1 participant