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 @@ -3,6 +3,7 @@
import io.swagger.models.*;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.refs.RefFormat;
Expand Down Expand Up @@ -218,6 +219,12 @@ private void processProperties(final Map<String, Property> subProps, final Strin
if (arrayProp.getItems() instanceof RefProperty) {
processRefProperty((RefProperty) arrayProp.getItems(), file);
}
if (arrayProp.getItems() != null){
if (arrayProp.getItems() instanceof ObjectProperty) {
ObjectProperty objectProperty = (ObjectProperty) arrayProp.getItems();
processProperties(objectProperty.getProperties(), file);
}
}
} else if (prop.getValue() instanceof MapProperty) {
MapProperty mapProp = (MapProperty) prop.getValue();
if (mapProp.getAdditionalProperties() instanceof RefProperty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.swagger.models.properties.ByteArrayProperty;
import io.swagger.models.properties.IntegerProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
Expand Down Expand Up @@ -54,6 +55,19 @@

public class SwaggerParserTest {

@Test
public void testIssueRelativeRefs2(){
String location = "exampleSpecs/specs/my-domain/test-api/v1/test-api-swagger_v1.json";
Swagger swagger = new SwaggerParser().read(location, null, true);
assertNotNull(swagger);
Map<String, Model> definitions = swagger.getDefinitions();
Assert.assertTrue(definitions.get("confirmMessageType_v01").getProperties().get("resources") instanceof ArrayProperty);
ArrayProperty arraySchema = (ArrayProperty) definitions.get("confirmMessageType_v01").getProperties().get("resources");
ObjectProperty prop = (ObjectProperty) arraySchema.getItems();
RefProperty refProperty = (RefProperty) prop.getProperties().get("resourceID");
assertEquals(refProperty.get$ref(),"#/definitions/simpleIDType_v01");
}

@Test
public void testIssue845() {
SwaggerDeserializationResult swaggerDeserializationResult = new SwaggerParser().readWithInfo("");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"description": "",
"type": "object",
"properties": {
"confirmMessageID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"processID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"processStatus": {
"description": "",
"type": "string",
"enum": [
"success", "partial-failure", "failure"
]
},
"resources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"resourceID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"resourceReference": {
"description": "",
"type": "string"
},
"resourceStatus": {
"description": "",
"type": "string",
"enum": [
"success", "partial-failure", "failure"
]
}
}
}
},
"links": {
"type": "array",
"items": {
"$ref": "./linkType_v01.json"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"description": "",
"type": "object",
"properties": {
"confirmMessageID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"processID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"processStatus": {
"description": "",
"type": "string",
"enum": [
"success", "partial-failure", "failure"
]
},
"resources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"resourceID": {
"description": "",
"$ref": "./simpleIDType_v01.json"
},
"resourceReference": {
"description": "",
"type": "string"
},
"resourceStatus": {
"description": "",
"type": "string",
"enum": [
"success", "partial-failure", "failure"
]
}
}
}
},
"links": {
"type": "array",
"items": {
"$ref": "./linkType_v01.json"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "date",
"description": "The string representation",
"type": "string",
"format": "date"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"title": "link",
"description": "A link description object",
"type": "object",
"properties": {
"href": {
"$ref": "./simpleIDType_v01.json"
},
"mediaType": {
"description": "media type description",
"type": "string",
"enum": [
"application/gzip",
"application/json",
"application/msword",
"application/pdf",
"application/postscript",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/xml",
"application/x-www-form-urlencoded",
"image/gif",
"image/jpeg",
"image/png",
"image/tiff",
"multipart/mixed",
"text/html",
"text/plain",
"application/vnd.visio",
"image/bmp",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.ms-powerpoint",
"video/mp4",
"audio/mpeg",
"video/x-msvideo",
"video/x-ms-wmv",
"application/rtf",
"application/vnd.ms-outlook",
"text/csv",
"video/quicktime",
"application/zip",
"application/illustrator",
"text/xml"
]
},
"payloadArguments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"argumentPath": {
"description": "payloadArguments",
"type": "string"
},
"argumentValue": {
"description": "payloadArguments",
"type": "string"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "simpleID",
"description": "Simple (string) identifier of an object to be used when there is no appropriate specific named ID Type",
"type": "string",
"pattern": "^[a-zA-Z0-9.$-_\/]+$"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"description": "Description",
"type": "object",
"properties": {
"testingApi": {
"type": "array",
"items": {
"title": "testingApi",
"type": "object",
"properties": {
"itemID": {
"$ref": "../../../../common/simpleIDType_v01.json"
},
"testLink": {
"type": "array",
"items": {
"$ref": "../../../../common/linkType_v01.json"
}
}
},
"additionalProperties": false
}
},
"_confirmMessage": {
"$ref": "../../../../common/confirmMessageType_v01.json"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"description": "Test Description",
"type": "object",
"properties": {
"testingApi": {
"type": "array",
"items": {
"title": "testingApi",
"type": "object",
"properties": {
"itemID": {
"$ref": "../../../../common/simpleIDType_v01.json"
},
"testLink": {
"type": "array",
"items": {
"$ref": "../../../../common/linkType_v01.json"
}
}
},
"additionalProperties": false
}
},
"_confirmMessage": {
"$ref": "../../../../common/confirmMessageType_v02.json"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"swagger": "2.0",
"info": {
"description": "APIs to retrieve some data",
"version": "1.0",
"title": "TEST A NEW API",
"contact": {
"name": "mine",
"email": "mine@me.com"
}
},
"tags": [
{
"name": "Test",
"description": "APIs to retrieve some data"
}
],
"paths": {
"/my-domain/v1/test-system": {
"get": {
"description": "Retrieve relevant data",
"tags": [
"Test"
],
"summary": "Retrieve relevant data",
"responses": {
"200": {
"description": "Request was successful",
"headers": {
},
"schema": {
"$ref": "./schemas/test-api-schema_v02.json"
}
},
"400": {
"$ref": "#/responses/400"
}
}
}
}
},
"definitions": {
},
"responses": {
"200": {
"description": "OK",
"headers": {
}
},
"400": {
"description": "Bad Request",
"headers": {
},
"schema": {
"$ref": "../../../common/confirmMessageType_v01.json"
}
}
},
"parameters": {
"asOfDate": {
"name": "asOfDate",
"in": "query",
"description": "date",
"required": false,
"example": "2017-01-01"
},
"header_Accept-Language": {
"name": "Accept-Language",
"in": "header",
"description": "Accept-Language",
"required": false,
"schema": {
"type": "string"
}
}
}

}