-
Notifications
You must be signed in to change notification settings - Fork 6k
$ref in additionalProperties in external yaml ignored #4135
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
Comments
@jimschubert Yes I think so. This talks about $ref within the external file. The $ref from the main swagger to the external file works ok. But: The $ref from The swagger example in initial description is the external file (just updated as |
I think this is not supported in the parser. Do you mind opening an issue there? |
Opened against swagger-parser as #342. Should this be closed or should we wait for the fix of swagger-parser and the verify it? |
@rakus let's leave this open for the time being. |
We just ran up against this. Any news or updates? One other question: how is this intended to be implemented? Specifically, would it be possible to specify package names per included file in some way? To explain, we're working on a number of APIs and want to have a common.yml with certain shared object/parameter definitions. let's say I have two APIs, Foo and bar, each in their own files which reference an ErrorMessage object in common.yml Currently if I run the codegen for Foo it generates it with a class called CommonYamldefinitionsErrorMessage in my com.example.api.foo package, but that class isn't created. What I'd like is for it to generate with an ErrorMessage class imported from com.example.api.common. That way both the APIs can refer to the same object. This makes most sense of using external files IMO - if I'm not sharing anything i can put everything in one more easily. I understand this might be out-of-scope for this ticket, but wanted to raise it. |
I have a work-around for this. it's a bit (lot) of a hack, but it works. What I do is:
|
Uh oh!
There was an error while loading. Please reload this page.
Description
The $ref below additionalProperties is not handled when the definition is kept in a seperate yaml file.
So the class needed for the reference is not created.
If the example YAML below is in a seperate file, the classes Result and LinkObject are created, but RelData is not.
If it is copied into the main swagger file, all classes are created.
The attached maven project shows the problem.
src/main/resources/Test1.yaml
contains definitions in main filesrc/main/resources/Test2.yaml
references definitions from external fileTest2Globals.yaml
Just build the project with
mvn generate-sources
and then compare the generated code intarget/generated-sources-good
andtarget/generated-sources-bad
.Maven project: swagger-addprop-bug.zip
Swagger-codegen version
Maven Plugin Version 2.2.2-SNAPSHOT (locally build)
Swagger declaration file content or url
globals.yaml:
The object
result
is referenced from the main swagger file. The ref fromresult._links
tolink-object
works, but the ref fromlink-object
torel-data
is ignored.Command line used for generation
Using Maven, like so:
Steps to reproduce
See attached maven project.
Related issues
Nothing found
Suggest a Fix
None.
The text was updated successfully, but these errors were encountered: