Skip to content

Commit

Permalink
Merge pull request #1109 from swagger-api/issue-1094
Browse files Browse the repository at this point in the history
fix for Issue #1094
  • Loading branch information
gracekarina authored May 29, 2019
2 parents 86181e2 + e7daa56 commit c94eadc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
Expand Down Expand Up @@ -142,6 +143,23 @@ public List<Parameter> processParameters(List<Parameter> parameters) {
Schema schema = parameter.getSchema();
if(schema != null){
schemaProcessor.processSchema(schema);
}else if(parameter.getContent() != null){
Map<String,MediaType> content = parameter.getContent();
for( String mediaName : content.keySet()) {
MediaType mediaType = content.get(mediaName);
if(mediaType.getSchema()!= null) {
schema = mediaType.getSchema();
if (schema != null) {
schemaProcessor.processSchema(schema);
}
}
if(mediaType.getExamples() != null) {
for(Example ex: mediaType.getExamples().values()){
exampleProcessor.processExample(ex);
}
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void processPaths() {
final List<Parameter> processedPathParameters = parameterProcessor.processParameters(pathItem.getParameters());
pathItem.setParameters(processedPathParameters);

//addParametersToEachOperation(pathItem);

final Map<PathItem.HttpMethod, Operation> operationMap = pathItem.readOperationsMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,24 @@ public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final Hea
{
headerParameter.getSchema();
result = null;
headerParameter.getContent();
result = null;
queryParameter.getSchema();
result = null;
queryParameter.getContent();
result = null;
cookieParameter.getSchema();
result = null;
cookieParameter.getContent();
result = null;
pathParameter.getSchema();
result = null;
pathParameter.getContent();
result = null;
}
};
final List<Parameter> processedParameters = new ParameterProcessor(cache, openAPI)
.processParameters(Arrays.<Parameter>asList(headerParameter,
.processParameters(Arrays.asList(headerParameter,
queryParameter,
cookieParameter,
pathParameter));
Expand All @@ -78,8 +86,7 @@ public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final Hea
}

@Test
public void testProcessParameters_RefToHeader(
@Injectable final HeaderParameter resolvedHeaderParam) throws Exception {
public void testProcessParameters_RefToHeader(@Injectable final HeaderParameter resolvedHeaderParam) throws Exception {
expectedModelProcessorCreation();

final String ref = "#/components/parameters/foo";
Expand All @@ -90,11 +97,12 @@ public void testProcessParameters_RefToHeader(
{
resolvedHeaderParam.getSchema();
result = null;
resolvedHeaderParam.getContent();
result = null;
}
};

final List<Parameter> processedParameters = new ParameterProcessor(cache, openAPI)
.processParameters(Arrays.<Parameter>asList(refParameter));
final List<Parameter> processedParameters = new ParameterProcessor(cache, openAPI).processParameters(Arrays.asList(refParameter));

new FullVerifications(){{}};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public class OpenAPIV3ParserTest {
protected int serverPort = getDynamicPort();
protected WireMockServer wireMockServer;

@Test
public void testRemoteParameterIssue1094(@Injectable final List<AuthorizationValue> auths) throws Exception{

OpenAPI result = new OpenAPIV3Parser().read("issue-1094/swagger.yaml");
Assert.assertNotNull(result);
Assert.assertNotNull(result.getComponents().getSchemas().get("PlmnId"));

}

@Test
public void testIssue1071() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openapi: "3.0.0"
info:
version: 15.3.0
title: "Common Data Types"
paths: {}
components:
schemas:
PlmnId:
type: object
properties:
mcc:
type: string
mnc:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
openapi: "3.0.0"
info:
version: 15.3.0
title: test
paths:
/my-app:
get:
parameters:
- name: target-plmn-list
in: query
content:
application/json:
schema:
type: array
items:
$ref: 'common.yaml#/components/schemas/PlmnId'
minItems: 1
responses:
'200':
description: Expected response to a valid request
schema:
type: string

0 comments on commit c94eadc

Please sign in to comment.