-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
191 changed files
with
7,266 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/reference/AbstractVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package io.swagger.v3.parser.reference; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.Operation; | ||
import io.swagger.v3.oas.models.PathItem; | ||
import io.swagger.v3.oas.models.Paths; | ||
import io.swagger.v3.oas.models.examples.Example; | ||
import io.swagger.v3.oas.models.headers.Header; | ||
import io.swagger.v3.oas.models.links.Link; | ||
import io.swagger.v3.oas.models.media.Encoding; | ||
import io.swagger.v3.oas.models.media.MediaType; | ||
import io.swagger.v3.oas.models.media.Schema; | ||
import io.swagger.v3.oas.models.parameters.Parameter; | ||
import io.swagger.v3.oas.models.parameters.RequestBody; | ||
import io.swagger.v3.oas.models.responses.ApiResponse; | ||
import io.swagger.v3.oas.models.responses.ApiResponses; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
|
||
import java.util.List; | ||
|
||
public abstract class AbstractVisitor implements Visitor { | ||
|
||
@Override | ||
public OpenAPI visitOpenApi(OpenAPI openAPI){ | ||
return null; | ||
} | ||
@Override | ||
public Paths visitPaths(Paths paths){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Components visitComponents(Components components){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public PathItem visitPathItem(PathItem pathItem){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Parameter visitParameter(Parameter parameter){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Operation visitOperation(Operation operation){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Schema visitSchema(Schema schema, List<String> inheritedIds){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public ApiResponse visitResponse(ApiResponse response){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public RequestBody visitRequestBody(RequestBody requestBody){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Link visitLink(Link link){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public SecurityScheme visitSecurityScheme(SecurityScheme securityScheme){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public ApiResponses visitResponses(ApiResponses responses){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public MediaType visitMediaType(MediaType mediaType){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Encoding visitEncoding(Encoding encoding){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Header visitHeader(Header header){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Example visitExample(Example example){ | ||
return null; | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
...s/swagger-parser-v3/src/main/java/io/swagger/v3/parser/reference/DereferencerContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package io.swagger.v3.parser.reference; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.parser.core.models.AuthorizationValue; | ||
import io.swagger.v3.parser.core.models.ParseOptions; | ||
import io.swagger.v3.parser.core.models.SwaggerParseResult; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class DereferencerContext { | ||
|
||
protected final OpenAPI openApi; | ||
|
||
protected final List<AuthorizationValue> auths; | ||
protected final String rootUri; | ||
protected final ParseOptions parseOptions; | ||
protected String providedBaseUri; | ||
protected SwaggerParseResult swaggerParseResult; | ||
protected boolean addParametersToEachOperation = true; | ||
protected String currentUri; | ||
|
||
private Map<String, Reference> referenceSet = new LinkedHashMap<>(); | ||
|
||
public DereferencerContext( | ||
SwaggerParseResult swaggerParseResult, | ||
List<AuthorizationValue> auths, | ||
String rootUri, | ||
ParseOptions parseOptions, | ||
String providedBaseUri, | ||
Map<String, Reference> referenceSet, | ||
Boolean addParametersToEachOperation) { | ||
this.swaggerParseResult = swaggerParseResult; | ||
this.openApi = swaggerParseResult.getOpenAPI(); | ||
this.auths = auths; | ||
this.rootUri = rootUri; | ||
this.currentUri = rootUri; | ||
this.parseOptions = parseOptions; | ||
this.providedBaseUri = providedBaseUri; | ||
this.addParametersToEachOperation = addParametersToEachOperation != null ? addParametersToEachOperation : true; | ||
this.referenceSet = referenceSet != null ? referenceSet : new LinkedHashMap<>(); | ||
} | ||
|
||
public OpenAPI getOpenApi() { | ||
return openApi; | ||
} | ||
|
||
public List<AuthorizationValue> getAuths() { | ||
return auths; | ||
} | ||
|
||
public String getRootUri() { | ||
return rootUri; | ||
} | ||
|
||
public ParseOptions getParseOptions() { | ||
return parseOptions; | ||
} | ||
|
||
public String getProvidedBaseUri() { | ||
return providedBaseUri; | ||
} | ||
|
||
public SwaggerParseResult getSwaggerParseResult() { | ||
return swaggerParseResult; | ||
} | ||
|
||
public boolean isAddParametersToEachOperation() { | ||
return addParametersToEachOperation; | ||
} | ||
|
||
public void setAddParametersToEachOperation(boolean addParametersToEachOperation) { | ||
this.addParametersToEachOperation = addParametersToEachOperation; | ||
} | ||
|
||
public String getCurrentUri() { | ||
return currentUri; | ||
} | ||
|
||
public void setCurrentUri(String currentUri) { | ||
this.currentUri = currentUri; | ||
} | ||
|
||
public DereferencerContext providedBaseUri(String providedBaseUri) { | ||
this.providedBaseUri = providedBaseUri; | ||
return this; | ||
} | ||
|
||
public DereferencerContext swaggerParseResult(SwaggerParseResult swaggerParseResult) { | ||
this.swaggerParseResult = swaggerParseResult; | ||
return this; | ||
} | ||
|
||
public DereferencerContext addParametersToEachOperation(boolean addParametersToEachOperation) { | ||
this.addParametersToEachOperation = addParametersToEachOperation; | ||
return this; | ||
} | ||
|
||
public DereferencerContext currentUri(String currentUri) { | ||
this.currentUri = currentUri; | ||
return this; | ||
} | ||
|
||
public Map<String, Reference> getReferenceSet() { | ||
return referenceSet; | ||
} | ||
|
||
public void setReferenceSet(Map<String, Reference> referenceSet) { | ||
this.referenceSet = referenceSet; | ||
} | ||
|
||
public DereferencerContext referenceSet(Map<String, Reference> referenceSet) { | ||
this.referenceSet = referenceSet; | ||
return this; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../swagger-parser-v3/src/main/java/io/swagger/v3/parser/reference/DereferencersFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.swagger.v3.parser.reference; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
public class DereferencersFactory { | ||
|
||
private static DereferencersFactory instance; | ||
static Logger LOGGER = LoggerFactory.getLogger(DereferencersFactory.class); | ||
private final List<OpenAPIDereferencer> dereferencers; | ||
|
||
private DereferencersFactory() { | ||
dereferencers = new CopyOnWriteArrayList<>(); | ||
dereferencers.add(new OpenAPIDereferencer31()); | ||
} | ||
|
||
public static DereferencersFactory getInstance() { | ||
if (instance == null) { | ||
instance = new DereferencersFactory(); | ||
} | ||
return instance; | ||
} | ||
|
||
public void addDereferencer(OpenAPIDereferencer dereferencer) { | ||
dereferencers.add(0, dereferencer); | ||
} | ||
|
||
public void removeDereferencer(OpenAPIDereferencer dereferencer) { | ||
dereferencers.remove(dereferencer); | ||
} | ||
|
||
public List<OpenAPIDereferencer> getDereferencers() { | ||
return Collections.unmodifiableList(dereferencers); | ||
} | ||
|
||
static { | ||
ServiceLoader<OpenAPIDereferencer> loader = ServiceLoader.load(OpenAPIDereferencer.class); | ||
Iterator<OpenAPIDereferencer> itr = loader.iterator(); | ||
while (itr.hasNext()) { | ||
OpenAPIDereferencer ext = itr.next(); | ||
if (ext == null) { | ||
LOGGER.error("failed to load extension {}", ext); | ||
} else { | ||
instance.addDereferencer(ext); | ||
LOGGER.debug("adding OpenAPIDereferencer: {}", ext); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.