2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2019 AT&T Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music;
25 import io.swagger.jaxrs.config.BeanConfig;
26 import io.swagger.jaxrs.listing.ApiListingResource;
27 import io.swagger.jaxrs.listing.SwaggerSerializers;
29 import javax.annotation.PostConstruct;
31 import org.glassfish.jersey.server.ResourceConfig;
32 import org.onap.music.conductor.conditionals.RestMusicConditionalAPI;
33 import org.onap.music.exceptions.MusicExceptionMapper;
34 import org.onap.music.rest.RestMusicDataAPI;
35 import org.onap.music.rest.RestMusicHealthCheckAPI;
36 import org.onap.music.rest.RestMusicLocksAPI;
37 import org.onap.music.rest.RestMusicQAPI;
38 import org.onap.music.rest.RestMusicTestAPI;
39 import org.onap.music.rest.RestMusicVersionAPI;
40 import org.springframework.beans.factory.annotation.Value;
41 import org.springframework.stereotype.Component;
44 public class JerseyConfig extends ResourceConfig {
46 @Value("${spring.jersey.application-path:/}")
47 private String apiPath;
49 public JerseyConfig() {
50 this.registerEndpoints();
51 register(MusicExceptionMapper.class);
56 this.configureSwagger();
59 private void registerEndpoints() {
60 register(RestMusicDataAPI.class);
61 register(RestMusicLocksAPI.class);
62 register(RestMusicConditionalAPI.class);
63 register(RestMusicQAPI.class);
64 register(RestMusicTestAPI.class);
65 register(RestMusicVersionAPI.class);
66 register(RestMusicHealthCheckAPI.class);
70 private void configureSwagger() {
71 // Available at localhost:port/swagger.json
72 this.register(ApiListingResource.class);
73 this.register(SwaggerSerializers.class);
75 BeanConfig config = new BeanConfig();
76 config.setConfigId("MUSIC");
77 config.setTitle("MUSIC");
78 config.setVersion("v2");
79 config.setContact("Thomas Nelson");
80 config.setSchemes(new String[] {"http", "https"});
81 config.setBasePath("/MUSIC/rest");
82 config.setResourcePackage("org.onap.music");
83 config.setPrettyPrint(true);