Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for Issue #1094 #1109

Merged
merged 3 commits into from
May 29, 2019
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 @@ -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