/*
 * Copyright 2017 FBK/CREATE-NET
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.createnet.raptor.service;

import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.models.Info;
import org.createnet.raptor.service.tools.RaptorApplicationEventListener;
import org.glassfish.jersey.server.ResourceConfig;

/**
 *
 * @author Luca Capra <lcapra@fbk.eu>
 */
abstract public class BaseAppConfig extends ResourceConfig {

    public void registerDefault() {
        register(RaptorApplicationEventListener.class);
        register(new ServiceBinder());
    }
    
    public void registerSwagger(String resourcePackage) {

        register(io.swagger.jaxrs.listing.ApiListingResource.class);
        register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
        
        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion("3.0");
        beanConfig.setSchemes(new String[]{"http", "https"});
        beanConfig.setHost("api.raptor.local");
        Info info = new Info();
        info.setTitle("Raptor API");
        beanConfig.setInfo(info);
        beanConfig.setBasePath("/");
        beanConfig.setResourcePackage(resourcePackage);
        beanConfig.setScan(true);
    }
    
}

@@ -705,16 +705,50 @@
 s.Info;%0A
+import io.swagger.models.License;%0A
 import o
@@ -813,16 +813,16 @@
 stener;%0A
-
 import o
@@ -1113,21 +1113,17 @@
 ;%0A    %7D%0A
-    
 %0A
+
     publ
@@ -1315,17 +1315,9 @@
 s);%0A
-        
 %0A
+
     
@@ -1358,24 +1358,72 @@
 anConfig();%0A
+        beanConfig.setTitle(%22Raptor HTTP API%22);%0A
         bean
@@ -1554,24 +1554,25 @@
 or.local%22);%0A
+%0A
         Info
@@ -1620,32 +1620,321 @@
 (%22Raptor API%22);%0A
+        info.setDescription(%22The IoT platform%22);%0A        info.setLicense(%0A                new License()%0A                        .name(%22Apache v2%22)%0A                        .url(%22https://raw.githubusercontent.com/raptorbox/raptor/master/LICENSE%22)%0A        );%0A        info.setVersion(%223.0%22);%0A%0A
         beanConf
@@ -2084,15 +2084,11 @@
 ;%0A    %7D%0A
-    
 %0A%7D%0A

add title to swagger api