swagger-api / swagger-api/swagger-parser
Nested references are not resolved for local files
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
If #454 testcases are changed to use a relative file reference, the nested definitions are not resolved.
tags:
- name: admins
description: Secured Admin-only calls
- name: developers
description: Operations available to regular developers
paths:
/inventory:
get:
summary: searches inventory test
operationId: searchInventory
responses:
200:
description: search results matching criteria
default:
$ref: './issue-454-file-components.yaml#/responses/GeneralError'
definitions:
ModelWithNestedProperties:
properties:
remoteProperty:
$ref: './issue-454-file-components.yaml#/definitions/RemoteComponent'
Test case:
@Test
public void testNestedFileRefs() {
Swagger swagger = new SwaggerParser().read("src/test/resources/nested-file-references/issue-454-file.yaml",
null, true);
assertNotNull(swagger.getDefinitions().get("ErrorModel"));
assertNotNull(swagger.getDefinitions().get("ModelWithNestedProperties"));
ModelImpl model = (ModelImpl)swagger.getDefinitions().get("ModelWithNestedProperties");
Property property = model.getProperties().get("remoteProperty");
assertNotNull(property);
assertTrue(property instanceof RefProperty);
RefProperty ref = (RefProperty) property;
assertEquals(ref.get$ref(), "#/definitions/RemoteComponent");
assertNotNull(swagger.getDefinitions().get("NestedProperty"));
ModelImpl nestedModel = (ModelImpl)swagger.getDefinitions().get("NestedProperty");
assertNotNull(nestedModel);
assertNotNull(nestedModel.getProperties().get("name"));
assertTrue(nestedModel.getProperties().get("name") instanceof StringProperty);
}
The attached tar ball contains a testcase and test data to reproduce the issue.
test.tar.gz
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 with the nested-file-references/issue-454-file.yaml fixture and run SwaggerParser.read as shown in testNestedFileRefs. Compare the resolved definitions and remoteProperty reference with the assertions in the test; done means the nested references resolve and all listed assertions pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, yaml
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100