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

Path not present: components #230

Open
grnadav opened this issue Dec 12, 2023 · 0 comments
Open

Path not present: components #230

grnadav opened this issue Dec 12, 2023 · 0 comments

Comments

@grnadav
Copy link

grnadav commented Dec 12, 2023

Hello,
When running the maven plugin on a json file (de-refed, all local definitions),
It can't find components in the json OpenAPI.
But it is there.
Using that JSON file we are able to generate a REST service using the generic OpenAPI generation tool.

Update:
Issue is with the ref of stuff_alias_identifier to base_identifier inside the components.
When embedded directly (removing base_identifier and writing its contents inside the other *_identifiers, it is able to generate the service.

we get this error:

Error from PROJECT_GENERATION_FAILED.txt :

Server Stack Trace:
java.lang.IllegalArgumentException: Path not present: components
	at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:55)
	at org.jsonschema2pojo.FragmentResolver.resolve(FragmentResolver.java:31)
	at org.jsonschema2pojo.SchemaStore.create(SchemaStore.java:138)
	at io.apicurio.hub.api.codegen.OpenApi2JaxRs$2.create(OpenApi2JaxRs.java:885)
	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:69)
	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:38)
	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:85)
	at org.jsonschema2pojo.rules.PropertyRule.apply(PropertyRule.java:42)
	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:70)
	at org.jsonschema2pojo.rules.PropertiesRule.apply(PropertiesRule.java:38)
	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:120)
	at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:65)
	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:86)
	at org.jsonschema2pojo.rules.TypeRule.apply(TypeRule.java:41)
	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:83)
	at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:38)
	at org.jsonschema2pojo.SchemaMapper.generate(SchemaMapper.java:135)
	at io.apicurio.hub.api.codegen.OpenApi2JaxRs.generateJavaBean(OpenApi2JaxRs.java:890)
	at io.apicurio.hub.api.codegen.OpenApi2JaxRs.generateAll(OpenApi2JaxRs.java:290)
	at io.apicurio.hub.api.codegen.OpenApi2JaxRs.generate(OpenApi2JaxRs.java:216)
	at io.apicurio.codegen.maven.GenerateCodeMojo.execute(GenerateCodeMojo.java:77)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
	at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
	at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
	at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:906)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:283)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:283)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:226)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:407)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

Reproducing sample:

{
  "openapi" : "3.0.3",
  "info" : {
    "title" : "Stuff alias actions in the stuff service",
    "version" : "1.0.0"
  },
  "servers" : [ {
    "url" : "/"
  } ],
  "tags" : [ {
    "name" : "StuffAlias"
  } ],
  "paths" : {
    "/api/rest/v1/stuff/alias/" : {
      "post" : {
        "tags" : [ "StuffAlias" ],
        "summary" : "Create a stuff alias",
        "operationId" : "stuffAliasCreate",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/CreateStuffAliasRequestBody"
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "description" : "Successfully created",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/CreateStuffAliasResponseBody"
                }
              }
            }
          }
        }
      }
    }

  },
  "components" : {
    "schemas" : {
      "CreateStuffAliasRequestBody" : {
        "required" : [ "stuffId" ],
        "type" : "object",
        "properties" : {
          "stuffId" : {
            "$ref" : "#/components/schemas/stuff_identifier"
          }
        }
      },
      "CreateStuffAliasResponseBody" : {
        "required" : [ "stuffAliasId" ],
        "type" : "object",
        "properties" : {
          "stuffAliasId" : {
            "$ref" : "#/components/schemas/stuff_alias_identifier"
          }
        }
      },
      "stuff_alias_identifier" : {
        "$ref" : "#/components/schemas/base_identifier"
      },
      "base_identifier" : {
        "type" : "string",
        "format" : "uuid"
      },
      "stuff_identifier" : {
        "$ref" : "#/components/schemas/base_identifier"
      }
    }
  }
}
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