OpenAPITools / OpenAPITools/openapi-generator
[BUG] YAML reference is not supported in openapi 3.0.0
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Reference & and * feature in YAML is not supported in openapi 3.0.0
openapi-generator version
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.3.4</version>
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 0.0.1
title: AIML Feasture Ingestion Service
termsOfService: http://swagger.io/terms/
servers:
- url: https://petstore.swagger.io/v1
paths:
/job_runs:
post:
tags:
- job_runs
summary: Trigger a NEW ingestion job run
description: ""
operationId: triggerJobRun
requestBody:
description: Request body that needs to trigger a job
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/JobRunRequest"
responses:
"404":
description: Feasture set ID/version not found
"200":
description: Success
/job_runs/{job_run_id}:
get:
tags:
- job_runs
summary: Get an ingestion job run
description: ""
parameters:
- name: job_run_id
in: path
description: The ID of the job run
schema:
type: string
required: true
responses:
"404":
description: Job run ID not found
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/JobRunResponse"
components:
schemas:
JobRunRequest:
type: object
properties: &request_prop
feature_set_id:
type: string
run_by:
type: string
correlation_id:
type: string
required:
- feature_set_id
- run_by
JobRunResponse:
type: object
properties:
<<: *request_prop
state:
type: string
enum:
- created
- started
- success
- error
error:
type: string
description: Error details for `error` state
create_time:
type: string
start_time:
type: string
end_time:
type: string
``
##### Generation Details
```log
[ERROR]
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: 1, Warning count: 0
Errors:
-attribute components.schemas.JobRunResponse.properties is not of type `object`
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput (CodegenConfigurator.java:569)
at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:607)
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 sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
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)
Steps to reproduce
- create a mvn project with open-api plugin to generate java codes.
- get the error in Generation Details
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied YAML declaration with the openapi-generator Maven plugin, following the validation failure at CodegenConfigurator. Trace how the components.schemas.JobRunResponse.properties value is parsed and validated; done means YAML anchors and merge keys are accepted in this OpenAPI 3.0.0 example and generation proceeds without the reported validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100