use of io.swagger.v3.parser.models.RefFormat in project swagger-parser by swagger-api.
the class RefUtils method computeRefFormat.
public static RefFormat computeRefFormat(String ref) {
RefFormat result = RefFormat.INTERNAL;
ref = mungedRef(ref);
if (ref.startsWith("http") || ref.startsWith("https")) {
result = RefFormat.URL;
} else if (ref.startsWith(REFERENCE_SEPARATOR)) {
result = RefFormat.INTERNAL;
} else if (ref.startsWith(".") || ref.startsWith("/") || ref.indexOf(REFERENCE_SEPARATOR) > 0) {
result = RefFormat.RELATIVE;
}
return result;
}
use of io.swagger.v3.parser.models.RefFormat in project swagger-parser by swagger-api.
the class ResolverFully method resolveHeader.
public Header resolveHeader(Header header) {
RefFormat refFormat = computeRefFormat(header.get$ref());
String $ref = header.get$ref();
if (!isAnExternalRefFormat(refFormat)) {
if (headers != null && !headers.isEmpty()) {
String referenceKey = computeDefinitionName($ref);
return headers.getOrDefault(referenceKey, header);
}
}
return header;
}
use of io.swagger.v3.parser.models.RefFormat in project swagger-parser by swagger-api.
the class ResolverFully method resolveCallback.
public Callback resolveCallback(Callback callback) {
RefFormat refFormat = computeRefFormat(callback.get$ref());
String $ref = callback.get$ref();
if (!isAnExternalRefFormat(refFormat)) {
if (callbacks != null && !callbacks.isEmpty()) {
String referenceKey = computeDefinitionName($ref);
return callbacks.getOrDefault(referenceKey, callback);
}
}
return callback;
}
use of io.swagger.v3.parser.models.RefFormat in project swagger-parser by swagger-api.
the class ResolverFully method resolveLink.
public Link resolveLink(Link link) {
RefFormat refFormat = computeRefFormat(link.get$ref());
String $ref = link.get$ref();
if (!isAnExternalRefFormat(refFormat)) {
if (links != null && !links.isEmpty()) {
String referenceKey = computeDefinitionName($ref);
Link link1 = links.getOrDefault(referenceKey, link);
if (link1 == null) {
return null;
}
resolveHeaders(link1.getHeaders());
return link1;
}
}
return link;
}
use of io.swagger.v3.parser.models.RefFormat in project swagger-parser by swagger-api.
the class ExampleProcessor method processReferenceExample.
private void processReferenceExample(Example example) {
RefFormat refFormat = computeRefFormat(example.get$ref());
String $ref = example.get$ref();
if (isAnExternalRefFormat(refFormat)) {
final String newRef = externalRefProcessor.processRefToExternalExample($ref, refFormat);
if (newRef != null) {
example.set$ref(newRef);
}
}
}
Aggregations