All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.anteros.jsondoc.springmvc.scanner.builder.SpringResponseBuilder Maven / Gradle / Ivy

The newest version!
package br.com.anteros.jsondoc.springmvc.scanner.builder;

import java.lang.reflect.Method;

import org.jsondoc.core.util.JSONDocType;
import org.jsondoc.core.util.JSONDocTypeBuilder;
import org.springframework.http.ResponseEntity;

import br.com.anteros.jsondoc.core.pojo.ApiResponseObjectDoc;

public class SpringResponseBuilder {

	/**
	 * Builds the ApiResponseObjectDoc from the method's return type and checks if the first type corresponds to a ResponseEntity class. In that case removes the "responseentity"
	 * string from the final list because it's not important to the documentation user.
	 * @param method
	 * @param apiResponseObjectDoc
	 * @return
	 */
	public static ApiResponseObjectDoc buildResponse(Method method) {
		ApiResponseObjectDoc apiResponseObjectDoc = new ApiResponseObjectDoc(JSONDocTypeBuilder.build(new JSONDocType(), method.getReturnType(), method.getGenericReturnType()));
		
		if(method.getReturnType().isAssignableFrom(ResponseEntity.class)) {
			apiResponseObjectDoc.getJsondocType().getType().remove(0);
		}
		
		return apiResponseObjectDoc;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy