Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -58,7 +59,7 @@ public class ResolverCache {
/*
a map that stores original external references, and their associated renamed references
*/
private Map<String, String> renameCache = new HashMap<>();
private Map<String, String> renameCache = new ConcurrentHashMap<>();

public ResolverCache(Swagger swagger, List<AuthorizationValue> auths, String parentFileLocation) {
this.swagger = swagger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,25 @@ private void processDiscriminator(String discriminator, Map<String, Property> pr
processRefProperty(new RefProperty(RefType.DEFINITION.getInternalPrefix()+name), file);
}
}


}else if (prop.getValue() instanceof RefProperty) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix formatting add space after bracket

String ref = ((RefProperty) prop.getValue()).getSimpleRef();
Map<String, String> renameCache = cache.getRenameCache();
for (String key : renameCache.keySet()) {
String value = renameCache.get(key);
if (value.equals(ref)) {
Object resolved = cache.getResolutionCache().get(key);
if(resolved != null) {
if (resolved instanceof ModelImpl) {
ModelImpl schema = (ModelImpl) resolved;
if (schema.getEnum() != null) {
for (String name : schema.getEnum()) {
processRefProperty(new RefProperty(RefType.DEFINITION.getInternalPrefix() + name), file);
}
}
}
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ public void testIssueDefinitionWithDots() {
assertNotNull(swagger);
}

@Test
public void testIssue995() {
Swagger swagger = new SwaggerParser().read("issue-995/digitalExp-Product-Unresolved.yaml");
assertNotNull(swagger);
assertTrue(swagger.getDefinitions().size() == 6);
assertNotNull(swagger.getDefinitions().get("MobileProduct"));
assertNotNull(swagger.getDefinitions().get("FixedVoiceProduct"));
assertNotNull(swagger.getDefinitions().get("InternetProduct"));
}

@Test
public void testIssue927() {
Swagger swagger = new SwaggerParser().read("issue-927/issue-927.yaml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
info:
description: "This is a common Domain"
version: "1.0"
title: Common Domain

responses:

400-BadRequest:
x-dox-Since: v10.2
description: Bad Request
schema:
$ref: "#/definitions/ErrorResponse"

definitions:
ErrorResponse:
x-dox-Since: v10.2
type: object
description: |
Response containing descriptive error text, error code
required:
- code
- message
properties:
code:
description: |
The code associated with the error
readOnly: true
type: integer
message:
description: |
The message associated with the error
readOnly: true
type: string

ChannelType:
type: string
enum:
- selfService
- retail
- callCenter

Product:
x-dox-Since: '10.2'
description: |
The respesentation of the product
type: object
discriminator: productType
required:
- productType
x-dox-discriminator-name: NAME
x-dox-discriminator-type:
- MobileProduct
- InternetProduct
- FixedVoiceProduct
properties:
id:
type: string
status:
type: string
name:
type: string
productType:
$ref: '#/definitions/ProductType'

ProductType:
x-dox-Since: '10.2'
description: |
The different type of products
enum:
- MobileProduct
- FixedVoiceProduct
- InternetProduct

MobileProduct:
x-dox-Since: 10.2
description: |
The instance of the mobile product being added.
type: object
allOf:
- $ref: "#/definitions/Product"
- type: object
properties:
sim:
type: string
phoneNumber:
type: string

FixedVoiceProduct:
x-dox-Since: 10.2
description: |
The instance of the fixed voice product being added.
type: object
allOf:
- $ref: "#/definitions/Product"
- type: object
properties:
phoneNumber:
type: string

InternetProduct:
x-dox-Since: 10.2
description: |
The instance of the internet product being added.
type: object
allOf:
- $ref: "#/definitions/Product"
- type: object
properties:
userName:
type: string
speed:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
swagger: '2.0'
info:
version: '1.0'
title: 'Product Operation'
description: 'Product Operation'


basePath: /commerce

consumes:
- application/json
produces:
- application/json

paths:

/v1/product/{productId}:
get:
summary: Get the product
description: Get the product
parameters:
- name: productId
in: path
required: true
type: string
responses:
200:
description: OK
schema:
$ref: 'digitalExp-CommonDefinitionDomain.yaml#/definitions/Product'
400:
$ref: 'digitalExp-CommonDefinitionDomain.yaml#/responses/400-BadRequest'