-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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] references to external files does not work #3233
Comments
I fear that this is an issue with Swagger-Parser. Since your example is quite big, it take some times to understand which part is broken. |
I encountered the same problem and it is indeed something about Swagger-Parser. To be more precise, I have had this problem when 1) defining content with reference schema for parameters and 2) referencing a requestBody component that has an external schema reference which also references another schema. #test.yaml
openapi: 3.0.0
info:
version: "1.0"
title: Swagger Parser Issue
paths:
/:
post:
parameters:
- name: param
in: query
required: true
content:
'application/json':
schema:
$ref: 'common.yaml#/components/schemas/ExternalSchema'
requestBody:
$ref: '#/components/requestBodies/RefRequestBody'
responses:
default:
description: "Error"
components:
requestBodies:
RefRequestBody:
required: true
content:
'application/json':
schema:
$ref: 'common.yaml#/components/schemas/ExternalSchema'
#common.yaml
openapi: 3.0.0
info:
version: "1.0"
title: Swagger Parser Issue
paths: {}
components:
schemas:
AnotherSchema:
type: string
ExternalSchema:
type: object
properties:
val:
$ref: '#/components/schemas/AnotherSchema' |
We are using: <dependency>
<groupId>org.openapitools.swagger.parser</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.13-OpenAPITools.org-1</version>
</dependency> and swagger-parser did publish an update recently. <dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.13</version>
</dependency> Test program:
We discussed already that we would like to update. I will see if we can do a @YishTish: I did not look, but I hope your problem is the same. |
I have started #3239 |
I've made some changes to the files in the gist. Apparently, there were some schema issues with them that I didn't realize. |
@jmini for my use now it works fine, the referenced schemes for parameters with content are referenced correctly. I do have a bug to report though, as this case that I was using for testing is still not working. #test.yaml
openapi: 3.0.0
info:
version: "1.0"
title: Swagger Parser Issue
paths:
/:
post:
requestBody:
$ref: '#/components/requestBodies/RefRequestBody'
responses:
default:
description: "Error"
components:
requestBodies:
RefRequestBody:
content:
'application/json':
schema:
$ref: 'common.yaml#/components/schemas/StringObject' With the external reference pointing to #common.yaml
openapi: 3.0.0
info:
version: "1.0"
title: Swagger Parser Issue
paths: {}
components:
schemas:
String:
type: string
StringObject:
type: object
properties:
val:
$ref: '#/components/schemas/String' This example results in "StringObject" : {
"type" : "object",
"properties" : {
"val" : {
"$ref" : "./common.yaml#/components/schemas/String"
}
},
"example" : {
"val" : "{}"
}
}, |
@DonDi94: thank you a lot for your example. IMO this is definitively an error produced by Swagger-Parser (that merges for us all separated files into a single one). I have raised swagger-api/swagger-parser#1147 with your example. |
@jmini no problem I'm glad to help! Yes I agree, the previously reported problem was for the exact same issue in referenced schemes in parameter's contents. In that case I was getting the same result with the |
swagger-api/swagger-parser#1147 seems to be fixed in @DonDi94: Can you try with the latest |
I tested on the previous case and it works, all the references are resolved correctly. |
Description
Generating code with references to external files does not work (used to work in V2).
stack trace (last lines):
openapi-generator version
4.0.2
OpenAPI declaration file content or url
https://gist.github.com/YishTish/d2f8335e6027f4d50beec84abdf20b90
Command line used for generation
regular bash: openapi-generator generate -i openapi.json -g openapi-yaml -o generated/
Steps to reproduce
Just run the code with the jsons specified.
Related issues/PRs
#3026
Suggest a fix
When $ref starts with './', change behaviour to pick up the data from external file. Note that the file location is always relative, and absolute path can (should?) be considered wrong.
The text was updated successfully, but these errors were encountered: