Package com.knappsack.swagger4springweb.parser

Source Code of com.knappsack.swagger4springweb.parser.ApiDescriptionParser

package com.knappsack.swagger4springweb.parser;


import com.knappsack.swagger4springweb.util.AnnotationUtils;
import com.wordnik.swagger.model.ApiDescription;
import scala.Option;

import java.lang.reflect.Method;

public class ApiDescriptionParser {

    /**
     * @param method Method - Controller method to investigate
     * @param description String - Description of this API
     * @param resourcePath String - the path of this API. For Spring MVC this would be the value of the RequestMapping
     * @return ApiDescription
     */
    public ApiDescription parseApiDescription(Method method, String description, String resourcePath) {
        String requestMappingValue = AnnotationUtils.getMethodRequestMappingValue(method);
        String path;
        if (resourcePath != null && !resourcePath.isEmpty()) {
            path = resourcePath + requestMappingValue;
        } else {
            path = requestMappingValue;
        }

        Option<String> descriptionOption = Option.apply(description);

        return new ApiDescription(path, descriptionOption, null);
    }
}
TOP

Related Classes of com.knappsack.swagger4springweb.parser.ApiDescriptionParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.