Skip to content

Commit

Permalink
Properly decode $ref
Browse files Browse the repository at this point in the history
  • Loading branch information
sbu-WBT committed Aug 12, 2020
1 parent c9939a2 commit 54bb382
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import java.math.BigDecimal;
import java.net.URI;
import java.net.URLDecoder;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -71,7 +72,7 @@ public class ModelUtils {
JSON_MAPPER = ObjectMapperFactory.createJson();
YAML_MAPPER = ObjectMapperFactory.createYaml();
}

public static void setDisallowAdditionalPropertiesIfNotPresent(boolean value) {
GlobalSettings.setProperty(disallowAdditionalPropertiesIfNotPresent, Boolean.toString(value));
}
Expand Down Expand Up @@ -386,7 +387,7 @@ public static String getSimpleRef(String ref) {

}

return ref;
return URLDecoder.decode(ref);
}

/**
Expand Down Expand Up @@ -1077,15 +1078,15 @@ public static Schema unaliasSchema(OpenAPI openAPI,

/**
* Returns the additionalProperties Schema for the specified input schema.
*
*
* The additionalProperties keyword is used to control the handling of additional, undeclared
* properties, that is, properties whose names are not listed in the properties keyword.
* The additionalProperties keyword may be either a boolean or an object.
* If additionalProperties is a boolean and set to false, no additional properties are allowed.
* By default when the additionalProperties keyword is not specified in the input schema,
* any additional properties are allowed. This is equivalent to setting additionalProperties
* to the boolean value True or setting additionalProperties: {}
*
*
* @param openAPI the object that encapsulates the OAS document.
* @param schema the input schema that may or may not have the additionalProperties keyword.
* @return the Schema of the additionalProperties. The null value is returned if no additional
Expand Down Expand Up @@ -1141,7 +1142,7 @@ public static Schema getAdditionalProperties(OpenAPI openAPI, Schema schema) {
}
return null;
}

public static Header getReferencedHeader(OpenAPI openAPI, Header header) {
if (header != null && StringUtils.isNotEmpty(header.get$ref())) {
String name = getSimpleRef(header.get$ref());
Expand Down Expand Up @@ -1478,12 +1479,12 @@ private static ObjectMapper getRightMapper(String data) {

/**
* Parse and return a JsonNode representation of the input OAS document.
*
*
* @param location the URL of the OAS document.
* @param auths the list of authorization values to access the remote URL.
*
*
* @throws java.lang.Exception if an error occurs while retrieving the OpenAPI document.
*
*
* @return A JsonNode representation of the input OAS document.
*/
public static JsonNode readWithInfo(String location, List<AuthorizationValue> auths) throws Exception {
Expand Down Expand Up @@ -1511,14 +1512,14 @@ public static JsonNode readWithInfo(String location, List<AuthorizationValue> au
/**
* Parse the OAS document at the specified location, get the swagger or openapi version
* as specified in the source document, and return the version.
*
*
* For OAS 2.0 documents, return the value of the 'swagger' attribute.
* For OAS 3.x documents, return the value of the 'openapi' attribute.
*
*
* @param openAPI the object that encapsulates the OAS document.
* @param location the URL of the OAS document.
* @param auths the list of authorization values to access the remote URL.
*
*
* @return the version of the OpenAPI document.
*/
public static SemVer getOpenApiVersion(OpenAPI openAPI, String location, List<AuthorizationValue> auths) {
Expand Down

0 comments on commit 54bb382

Please sign in to comment.