swagger-api / swagger-api/swagger-parser
setReference doesn't add a $ref to models?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Hey everybody,
So my issue is that when modifying a swagger.json file, when I try to add a definition with it's own model,
When I create my own model and try to set a reference to it, it seems to work. However, when I get the output from the swagger file with the .yaml output the reference isn't there at all.
My code is something like this
swaggerDefs = swagger.getDefinitions();
ModelImpl model2 = new ModelImpl();
model2.description("Placeholder");
model2.setFormat("");
model2.setType("object");
model2.setReference("#/definitions/example");
swaggerDefs.put("ex2, model2);
where swagger is the swaggerobj created from reading a swagger.json file.
I get an output like so in my yaml file with the reference not showing up.
ex2:
type: object
format: ""
description: PlaceHolder.
Is there something I'm doing wrong? Or is outputting the set reference broken?
Thank you.
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
Reproduce the example by reading swagger.json, creating a ModelImpl, calling setReference("#/definitions/example"), and serializing the result to YAML. Start at the getDefinitions/ModelImpl path involved in YAML output and compare the stored model with the emitted definition. Done means the ex2 definition preserves the expected $ref, or the issue is clarified with the observed limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100