2 * Copyright 2012-2015 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.music;
19 import io.swagger.jaxrs.config.BeanConfig;
20 import io.swagger.jaxrs.listing.ApiListingResource;
21 import io.swagger.jaxrs.listing.SwaggerSerializers;
22 import org.glassfish.jersey.server.ResourceConfig;
23 import org.onap.music.rest.*;
24 import org.springframework.beans.factory.annotation.Value;
25 import org.springframework.stereotype.Component;
27 import javax.annotation.PostConstruct;
29 @Component public class JerseyConfig extends ResourceConfig {
31 @Value("${spring.jersey.application-path:/}") private String apiPath;
33 public JerseyConfig() {
34 this.registerEndpoints();
37 @PostConstruct public void init() {
38 this.configureSwagger();
41 private void registerEndpoints() {
42 register(RestMusicAdminAPI.class);
43 register(RestMusicDataAPI.class);
44 register(RestMusicLocksAPI.class);
45 register(RestMusicQAPI.class);
46 register(RestMusicTestAPI.class);
47 register(RestMusicVersionAPI.class);
48 register(RestMusicHealthCheckAPI.class);
51 private void configureSwagger() {
52 //Available at localhost:port/swagger.json
53 this.register(ApiListingResource.class);
54 this.register(SwaggerSerializers.class);
56 BeanConfig config = new BeanConfig();
57 config.setConfigId("MUSIC");
58 config.setTitle("MUSIC");
59 config.setVersion("v2");
60 config.setContact("Thomas Nelson");
61 config.setSchemes(new String[] {"http", "https"});
62 config.setBasePath("/MUSIC/rest");
63 config.setResourcePackage("org.onap.music");
64 config.setPrettyPrint(true);