-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Bootstrap.java
46 lines (35 loc) · 1.84 KB
/
Bootstrap.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.wordnik.swagger.sample;
import com.wordnik.swagger.model.*;
import com.wordnik.swagger.config.*;
import com.wordnik.swagger.sample.util.*;
import com.wordnik.swagger.config.FilterFactory;
import javax.servlet.http.HttpServlet;
import java.util.List;
import java.util.ArrayList;
public class Bootstrap extends HttpServlet {
static {
// do any additional initialization here, such as set your base path programmatically as such:
// ConfigFactory.config().setBasePath("http://www.foo.com/");
ApiInfo info = new ApiInfo(
"Swagger Sample App", /* title */
"This is a sample server Petstore server. You can find out more about Swagger " +
"at <a href=\"http://swagger.wordnik.com\">http://swagger.wordnik.com</a> or on irc.freenode.net, #swagger. For this sample, " +
"you can use the api key \"special-key\" to test the authorization filters",
"http://helloreverb.com/terms/", /* TOS URL */
"apiteam@wordnik.com", /* Contact */
"Apache 2.0", /* license */
"http://www.apache.org/licenses/LICENSE-2.0.html" /* license URL */
);
List<AuthorizationScope> scopes = new ArrayList<AuthorizationScope>();
scopes.add(new AuthorizationScope("email", "Access to your email address"));
scopes.add(new AuthorizationScope("pets", "Access to your pets"));
List<GrantType> grantTypes = new ArrayList<GrantType>();
ImplicitGrant implicitGrant = new ImplicitGrant(
new LoginEndpoint("http://localhost:8002/oauth/dialog"),
"access_code");
grantTypes.add(implicitGrant);
AuthorizationType oauth = new OAuthBuilder().scopes(scopes).grantTypes(grantTypes).build();
ConfigFactory.config().addAuthorization(oauth);
ConfigFactory.config().setApiInfo(info);
}
}