forked from swagger-api/swagger-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for v3 programmatic interface
- Loading branch information
Showing
5 changed files
with
204 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-project</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-web</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<packaging>bundle</packaging> | ||
<name>swagger-web</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>javax.ws.rs-api</artifactId> | ||
<version>2.0.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-models</artifactId> | ||
<version>${models.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<defaultGoal>install</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>${felix-version}</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<id>set_failok</id> | ||
<goals> | ||
<goal>manifest</goal> | ||
</goals> | ||
<configuration> | ||
<instructions> | ||
<_failok>true</_failok> | ||
</instructions> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<manifestLocation>src/main/resources/META-INF</manifestLocation> | ||
<rebuildBundle>true</rebuildBundle> | ||
<instructions> | ||
<Export-Package>io.swagger.oas.web</Export-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<models.version>2.0.0-SNAPSHOT</models.version> | ||
</properties> | ||
</project> |
91 changes: 91 additions & 0 deletions
91
modules/swagger-web/src/main/java/io/swagger/oas/web/OpenAPIConfig.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,91 @@ | ||
package io.swagger.oas.web; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import io.swagger.oas.models.OpenAPI; | ||
|
||
public final class OpenAPIConfig { | ||
private Set<Class<?>> classesToBeScanned; | ||
private Map<String, Object> environment; | ||
private Class<?> filterClass; | ||
private Collection<String> ignoredRoutes; | ||
private OpenAPI openAPI; | ||
private boolean prettyPrint; | ||
private boolean scanAllResources; | ||
|
||
public OpenAPIConfig() { | ||
classesToBeScanned = Collections.<Class<?>>emptySet(); | ||
environment = Collections.<String, Object>emptyMap(); | ||
ignoredRoutes = Collections.<String>emptySet(); | ||
} | ||
|
||
public Set<Class<?>> getClasses() { | ||
return classesToBeScanned; | ||
} | ||
|
||
public OpenAPIConfig setClasses(Set<Class<?>> classesToBeScanned) { | ||
this.classesToBeScanned = classesToBeScanned == null || classesToBeScanned.isEmpty() | ||
? Collections.<Class<?>>emptySet() : Collections.unmodifiableSet(classesToBeScanned); | ||
return this; | ||
} | ||
|
||
public Class<?> getFilterClass() { | ||
return filterClass; | ||
} | ||
|
||
public OpenAPIConfig setFilterClass(Class<?> filterClass) { | ||
this.filterClass = filterClass; | ||
return this; | ||
} | ||
|
||
public Collection<String> getIgnoredRoutes() { | ||
return ignoredRoutes; | ||
} | ||
|
||
public OpenAPIConfig setIgnoredRoutes(Collection<String> ignoredRoutes) { | ||
this.ignoredRoutes = ignoredRoutes == null || ignoredRoutes.isEmpty() ? Collections.<String>emptySet() | ||
: Collections.unmodifiableCollection(new HashSet<String>(ignoredRoutes)); | ||
return this; | ||
} | ||
|
||
public OpenAPI getOpenAPI() { | ||
return openAPI; | ||
} | ||
|
||
public OpenAPIConfig setOpenAPI(OpenAPI openAPI) { | ||
this.openAPI = openAPI; | ||
return this; | ||
} | ||
|
||
public Map<String, Object> getUserDefinedOptions() { | ||
return environment; | ||
} | ||
|
||
public OpenAPIConfig setUserDefinedOptions(Map<String, Object> environment) { | ||
this.environment = environment == null || environment.isEmpty() ? Collections.<String, Object>emptyMap() | ||
: Collections.unmodifiableMap(new HashMap<>(environment)); | ||
return this; | ||
} | ||
|
||
public boolean isPrettyPrint() { | ||
return prettyPrint; | ||
} | ||
|
||
public OpenAPIConfig setPrettyPrint(boolean prettyPrint) { | ||
this.prettyPrint = prettyPrint; | ||
return this; | ||
} | ||
|
||
public boolean isScanAllResources() { | ||
return scanAllResources; | ||
} | ||
|
||
public void setScanAllResources(boolean scanAllResources) { | ||
this.scanAllResources = scanAllResources; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
modules/swagger-web/src/main/java/io/swagger/oas/web/OpenAPIController.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,7 @@ | ||
package io.swagger.oas.web; | ||
|
||
import java.util.Map; | ||
|
||
public interface OpenAPIController { | ||
OpenAPIConfig bootstrap(Map<String, Object> environment); | ||
} |
35 changes: 35 additions & 0 deletions
35
modules/swagger-web/src/main/java/io/swagger/oas/web/OpenAPIFilter.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,35 @@ | ||
package io.swagger.oas.web; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import io.swagger.oas.models.Operation; | ||
import io.swagger.oas.models.media.Schema; | ||
import io.swagger.oas.models.parameters.Parameter; | ||
|
||
public interface OpenAPIFilter { | ||
boolean isOperationAllowed( | ||
Operation operation, | ||
String path, | ||
String method, | ||
Map<String, List<String>> params, | ||
Map<String, String> cookies, | ||
Map<String, List<String>> headers); | ||
|
||
boolean isParamAllowed( | ||
Parameter parameter, | ||
Operation operation, | ||
String path, | ||
String method, | ||
Map<String, List<String>> params, | ||
Map<String, String> cookies, | ||
Map<String, List<String>> headers); | ||
|
||
boolean isPropertyAllowed( | ||
Schema<?> schema, | ||
Schema<?> property, | ||
String propertyName, | ||
Map<String, List<String>> params, | ||
Map<String, String> cookies, | ||
Map<String, List<String>> headers); | ||
} |
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