Repository navigation
More descriptive exceptions need to be thrown #133
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Im unable to debug my openapi.yaml file properly if this validation error is thrown.
I've got another validator for my openapi spec and this reports that my openapi spec has no validation errors.
Plugin settings:
<groupId>io.openapiprocessor</groupId>
<artifactId>openapi-processor-maven-plugin</artifactId>
<version>2021.1</version>
<configuration>
<id>openapi-generation</id>
<apiPath>${project.basedir}/openapi.yaml</apiPath>
</configuration>
<executions>
<execution>
<id>openapi-generation</id>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<id>spring</id>
<options>
<values>
<targetDir>${project.basedir}/target/generated-sources</targetDir>
<mapping>${project.basedir}/openapi-mapping.yaml</mapping>
<parser>OPENAPI4J</parser>
<showWarnings>true</showWarnings>
<bean-validation>true</bean-validation>
</values>
</options>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.openapiprocessor</groupId>
<artifactId>openapi-processor-core</artifactId>
<version>2021.4.2</version>
</dependency>
<dependency>
<groupId>io.openapiprocessor</groupId>
<artifactId>openapi-processor-spring</artifactId>
<version>2021.4</version>
</dependency>
</dependencies>
</plugin>
OpenAPI SPEC:
openapi: 3.0.3
info:
title: An API
version: '1.0'
paths:
/manager/epa:
patch:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseMessage'
responses:
'200':
description: Successfully executed
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseMessage'
'400':
description: Bad Request
$ref: '#/components/responses/404'
'404':
$ref: '#/components/responses/404'
'500':
description: Internal error
content:
application/json:
schema:
type: string
get:
parameters:
- in: query
name: id
schema:
type: string
required: true
description: Retrieve an instance
responses:
'200':
description: Successfully executed
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseMessage'
'400':
$ref: '#/components/schemas/ResponseMessage'
'404':
$ref: '#/components/responses/404'
'500':
description: Internal error
content:
application/json:
schema:
type: string
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
schemas:
ResponseMessage:
type: object
properties:
correlationId:
type: string
resultCode:
type: integer
resultDetails:
$ref: '#/components/schemas/MessageDetails'
MessageDetails:
type: object
properties:
exitCode:
type: integer
exitMessage:
type: string
res1:
type: string
res2:
type: string
stacktrace:
type: string
responses:
'200':
description: Successfully processed your request.
content:
text/plain:
schema:
$ref: '#/components/schemas/ResponseMessage'
'204':
description: Successfully updated
content:
text/plain:
schema:
$ref: '#/components/schemas/ResponseMessage'
'400':
description: The request was invalid
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseMessage'
'404':
description: Resource cannot be found or does not exist.
'500':
description:
Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseMessage'
security:
- basicAuth: []
Error thrown:
[ERROR] Failed to execute goal io.openapiprocessor:openapi-processor-maven-plugin:2021.1:process (openapi-generation) on project servicemanager-cc: openapi-processor-spring execution failed!: OpenApi3 validation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.openapiprocessor:openapi-processor-maven-plugin:2021.1:process (openapi-generation) on project servicemanager-cc: openapi-processor-spring execution failed!
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: openapi-processor-spring execution failed!
at io.openapiprocessor.maven.ProcessMojo.execute (ProcessMojo.java:67)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.openapi4j.core.validation.ValidationException: OpenApi3 validation failure
at org.openapi4j.parser.validation.v3.OpenApi3Validator.validate (OpenApi3Validator.java:28)
at org.openapi4j.parser.OpenApi3Parser.parse (OpenApi3Parser.java:41)
at org.openapi4j.parser.OpenApi3Parser.parse (OpenApi3Parser.java:17)
at org.openapi4j.parser.OpenApiParser.parse (OpenApiParser.java:53)
at io.openapiprocessor.core.parser.openapi4j.Parser.parse (Parser.kt:33)
at io.openapiprocessor.core.parser.Parser.parse (Parser.kt:29)
at io.openapiprocessor.spring.processor.SpringProcessor.run (SpringProcessor.kt:39)
at io.openapiprocessor.maven.ProcessorRunner.run (ProcessorRunner.java:31)
at io.openapiprocessor.maven.ProcessMojo.execute (ProcessMojo.java:60)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
SENIAN commentedon Aug 10, 2021
After some through debugging i've found out that i was copying from the yaml formatter to my IDE and losing the format. Resolved by copying without formatting from IDE pov. However maybe a proper yaml validator/openapi3 can be added?
hauner commentedon Aug 11, 2021
the processor does currently depend on the parser to provide validation info. Sometimes the parser output helps sometimes not :-( Having more specific validation would be nice.
Have to do some research :-)
hauner commentedon Aug 17, 2021
closing this one, the feature request moved to openapi-processor/openapi-processor-core#77
hauner commentedon Aug 26, 2021
since validation with the schema will probably not work I will take another look at the parser validation.
hauner commentedon Aug 27, 2021
ok, getting the following error when running via gradle but not when running via maven. So its is the maven plugin that does not print the validation messages.
SENIAN commentedon Oct 8, 2021
Thanks Hauner!
hauner commentedon Oct 10, 2021
improved in 2021.6
juliocauan commentedon Feb 24, 2022
So I've got the same error over here and I can't figure what's wrong with it
Plugin Settings:
Error thrown:
[ERROR] Failed to execute goal io.openapiprocessor:openapi-processor-maven-plugin:2021.1:process (default-cli) on project sboot-api-atom-global: openapi-processor-openapi-generation execution failed!: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.openapiprocessor:openapi-processor-maven-plugin:2021.1:process (default-cli) on project sboot-api-atom-global: openapi-processor-openapi-generation execution failed!
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: openapi-processor-openapi-generation execution failed!
at io.openapiprocessor.maven.ProcessMojo.execute (ProcessMojo.java:67)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
at java.io.File. (File.java:278)
at io.openapiprocessor.maven.ProcessMojo.execute (ProcessMojo.java:51)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
hauner commentedon Feb 25, 2022
The interesting lines in the error are:
The plugin creates a
Fileobject from thetargetDirpath. ButtargetDirisnull. It looks like the options/values map is empty.This is strange because I tried a sample with your configuration and it doesn't fail. So the configuration itself is ok.
Is it possible for you to provide a minimal project that shows the error?
I will add a few validations to the plugin that will check & report problem with the options. It should help to understand why the options are empty.
juliocauan commentedon Feb 25, 2022
sboot-api-atom-global.yaml:
Mapping.yaml:
Is there anything else I should provide?
hauner commentedon Feb 26, 2022
Hmm, how do you run it?
I just noticed that when I run
openapiprocessor:processdirectly it fails. It fails with same error you see. When I run it via lifecyclecompileit works.No idea yet, what I'm doing wrong in the plugin. Looking into it.
hauner commentedon Feb 26, 2022
Found something,
looks like the
<options>should be configured on<plugin>level and not at the<execution>level.I don't fully understand at the moment what the difference is. My maven know-how is a bit limited. ;-)
Here is an example with the moved options:
hauner commentedon Feb 26, 2022
I learned a few things about maven today and I found a "simpler" solution.
just change you original configuration
before:
to
after:
The
<id>is different. If the id isdefault-climaven will use the execution when running the goal directly with something like./mvnw openapi-processor:processand it will also use it when the given phase is active.juliocauan commentedon Feb 27, 2022
Thanks Hauner!! This really solved my problem!
hauner commentedon Feb 28, 2022
Thanks for reporting and for confirming that it helped. :-)