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.exceptions.MusicExceptionMapper;
24 import org.onap.music.rest.*;
25 import org.springframework.beans.factory.annotation.Value;
26 import org.springframework.stereotype.Component;
28 import javax.annotation.PostConstruct;
30 @Component public class JerseyConfig extends ResourceConfig {
32 @Value("${spring.jersey.application-path:/}") private String apiPath;
34 public JerseyConfig() {
35 this.registerEndpoints();
36 register(MusicExceptionMapper.class);
39 @PostConstruct public void init() {
40 this.configureSwagger();
43 private void registerEndpoints() {
44 register(RestMusicAdminAPI.class);
45 register(RestMusicDataAPI.class);
46 register(RestMusicLocksAPI.class);
47 register(RestMusicQAPI.class);
48 register(RestMusicTestAPI.class);
49 register(RestMusicVersionAPI.class);
50 register(RestMusicHealthCheckAPI.class);
53 private void configureSwagger() {
54 //Available at localhost:port/swagger.json
55 this.register(ApiListingResource.class);
56 this.register(SwaggerSerializers.class);
58 BeanConfig config = new BeanConfig();
59 config.setConfigId("MUSIC");
60 config.setTitle("MUSIC");
61 config.setVersion("v2");
62 config.setContact("Thomas Nelson");
63 config.setSchemes(new String[] {"http", "https"});
64 config.setBasePath("/MUSIC/rest");
65 config.setResourcePackage("org.onap.music");
66 config.setPrettyPrint(true);