Example usage for org.springframework.web.bind.annotation RequestMethod PATCH

List of usage examples for org.springframework.web.bind.annotation RequestMethod PATCH

Introduction

In this page you can find the example usage for org.springframework.web.bind.annotation RequestMethod PATCH.

Prototype

RequestMethod PATCH

To view the source code for org.springframework.web.bind.annotation RequestMethod PATCH.

Click Source Link

Usage

From source file:com.nagarro.core.v2.controller.CustomerGroupsController.java

/**
 * Assigns user(s) to a customer group./*from  www .ja  v a2s  .com*/
 *
 * @param members
 *           List of users to assign to customer group.
 * @bodyparams members.uid
 */
@RequestMapping(value = "/{groupId}/members", method = RequestMethod.PATCH, consumes = {
        MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@Secured("ROLE_CUSTOMERMANAGERGROUP")
@ResponseStatus(value = HttpStatus.OK)
public void assignUserToCustomerGroup(@PathVariable final String groupId,
        @RequestBody final MemberListWsDTO members) {
    validate(members.getMembers(), "members", principalListDTOValidator);

    for (final PrincipalWsDTO member : members.getMembers()) {
        customerGroupFacade.addUserToCustomerGroup(groupId, member.getUid());
    }
}

From source file:com.boundlessgeo.geoserver.api.controllers.WorkspaceController.java

@RequestMapping(value = "/{wsName:.+}", method = RequestMethod.PATCH)
public @ResponseBody JSONObj patch(@PathVariable String wsName, @RequestBody JSONObj obj) {
    return put(wsName, obj);
}

From source file:org.jrb.lots.web.controller.TagController.java

/**
 * RESTful CRUD endpoint to update an existing tag.
 * /* ww w  .j  a  v  a  2s . c  o m*/
 * @param tagId
 *            the identifier of the tag to be updated
 * @param tag
 *            the tag updates
 * @return a Spring MVC response containing the updated tag
 * @throws InvalidTagException
 *             if the tag updates do not pass the established validation
 *             rules
 * @throws UnknownTagException
 *             if attempt made to updated an unregistered tag
 * @throws TagServiceException
 *             if an unexpected error occurred while updating a tag
 */
@RequestMapping(value = "{tagId}", method = RequestMethod.PATCH)
public ResponseEntity<TagResponse> updateTag(@PathVariable final Long tagId, @RequestBody final Tag tag)
        throws InvalidTagException, UnknownTagException, TagServiceException {
    return controllerUtils.updateEntity(tagId, tag, Tag.class, TagResponse.class, TagController.class,
            new UpdateEntityCallback<Tag>() {
                @Override
                public Tag updateEntity(Long entityId, Tag submitted) throws ServiceException {
                    final Tag existing = tagService.findTag(tagId);
                    final Tag.Builder builder = new Tag.Builder().from(existing);
                    if (controllerUtils.different(submitted.getName(), existing.getName())) {
                        builder.setName(submitted.getName());
                    }
                    if (controllerUtils.different(submitted.getDescription(), existing.getDescription())) {
                        builder.setDescription(submitted.getDescription());
                    }
                    return tagService.updateTag(builder.build());
                }
            });
}

From source file:org.jrb.lots.web.controller.ThingController.java

/**
 * RESTful CRUD endpoint to update an existing thing.
 * // w ww.  ja v a2 s . c om
 * @param thingId
 *            the identifier of the thing to be updated
 * @param thing
 *            the thing updates
 * @return a Spring MVC response containing the updated thing
 * @throws InvalidThingException
 *             if the thing updates do not pass the established validation
 *             rules
 * @throws UnknownThingException
 *             if attempt made to updated an unregistered thing
 * @throws ThingServiceException
 *             if an unexpected error occurred while updating a thing
 */
@RequestMapping(value = "{thingId}", method = RequestMethod.PATCH)
public ResponseEntity<ThingResponse> updateThing(@PathVariable final Long thingId,
        @RequestBody final Thing thing)
        throws InvalidThingException, UnknownThingException, ThingServiceException {
    return controllerUtils.updateEntity(thingId, thing, Thing.class, ThingResponse.class, ThingController.class,
            new UpdateEntityCallback<Thing>() {
                @Override
                public Thing updateEntity(Long entityId, Thing submitted) throws ServiceException {
                    final Thing existing = thingService.findThing(thingId);
                    final Thing.Builder builder = new Thing.Builder().from(existing);
                    if (controllerUtils.different(submitted.getName(), existing.getName())) {
                        builder.setName(submitted.getName());
                    }
                    if (controllerUtils.different(submitted.getDescription(), existing.getDescription())) {
                        builder.setDescription(submitted.getDescription());
                    }
                    return thingService.updateThing(builder.build());
                }
            });
}

From source file:org.jrb.docasm.web.controller.DocumentController.java

/**
 * RESTful CRUD endpoint to update an existing document.
 * /*w w w .  j a  v a  2 s .  co  m*/
 * @param documentId
 *            the identifier of the document to be updated
 * @param document
 *            the document updates
 * @return a Spring MVC response containing the updated document
 * @throws InvalidDocumentException
 *             if the document updates do not pass the established
 *             validation rules
 * @throws UnknownDocumentException
 *             if attempt made to updated an unregistered document
 * @throws DocumentServiceException
 *             if an unexpected error occurred while updating a document
 */
@RequestMapping(value = "{documentId}", method = RequestMethod.PATCH)
public ResponseEntity<DocumentResponse> updateDocument(@PathVariable final Long documentId,
        @RequestBody final Document document)
        throws InvalidDocumentException, UnknownDocumentException, DocumentServiceException {
    return controllerUtils.updateEntity(documentId, document, Document.class, DocumentResponse.class,
            DocumentController.class, new UpdateEntityCallback<Document>() {
                @Override
                public Document updateEntity(Long entityId, Document submitted) {
                    final Document existing = documentService.findDocument(documentId);
                    final Document.Builder builder = new Document.Builder().from(existing);
                    if (controllerUtils.different(submitted.getName(), existing.getName())) {
                        builder.setName(submitted.getName());
                    }
                    if (controllerUtils.different(submitted.getTemplateUri(), existing.getTemplateUri())) {
                        builder.setTemplateUri(submitted.getTemplateUri());
                    }
                    if (controllerUtils.different(submitted.getDescription(), existing.getDescription())) {
                        builder.setDescription(submitted.getDescription());
                    }
                    return documentService.updateDocument(builder.build());
                }
            });
}

From source file:springfox.documentation.spring.data.rest.EntityRequestHandler.java

@Override
public ResolvedType getReturnType() {
    if (resourceType == ResourceType.COLLECTION) {
        if (COLLECTION_COMPACT_MEDIA_TYPES
                .containsAll(requestMapping.getProducesCondition().getProducibleMediaTypes())) {
            return resolver.resolve(Resources.class, Link.class);
        } else if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.HEAD)
                || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.OPTIONS)) {
            return resolver.resolve(Void.TYPE);
        } else if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.POST)) {
            return resolver.resolve(Resource.class, domainType);
        }/*from   w w w .j a v  a  2  s .com*/
        return resolver.resolve(Resources.class, domainType);
    } else {
        if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.GET)
                || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.PUT)
                || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.PATCH)) {
            return resolver.resolve(Resource.class, domainType);
        }
    }
    return resolver.resolve(Void.TYPE);
}

From source file:de.metas.ui.web.window.controller.WindowRestController.java

@RequestMapping(value = "/{windowId}/{documentId}", method = RequestMethod.PATCH)
public List<JSONDocument> patchRootDocument(@PathVariable("windowId") final int adWindowId //
        , @PathVariable("documentId") final String documentIdStr //
        ,/*from  w ww .  j  a  va2  s. com*/
        @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced //
        , @RequestBody final List<JSONDocumentChangedEvent> events) {
    final DocumentPath documentPath = DocumentPath.builder().setDocumentType(DocumentType.Window, adWindowId)
            .setDocumentId(documentIdStr).allowNewDocumentId().build();

    return patchDocument(documentPath, advanced, events);
}

From source file:com.castlemock.web.mock.rest.web.rest.controller.RestServiceController.java

/**
 * The service is responsible for handling all the incoming REST requests. The REST requests will be processed
 * and a response will be generated and returned to the service consumer.
 * @param projectId The id of the project that the request belongs to
 * @param applicationId The id of the application that the request belongs to
 * @param httpServletRequest The incoming request that will be processed
 * @param httpServletResponse The outgoing response
 * @return Returns a mocked response/*from  ww w . j  av  a 2  s  .  co m*/
 * @see RestProject
 * @see RestResource
 * @see RestMockResponse
 */
@ResponseBody
@RequestMapping(method = RequestMethod.PATCH, value = "/{projectId}/application/{applicationId}/**")
public ResponseEntity patchMethod(@PathVariable final String projectId,
        @PathVariable final String applicationId, final HttpServletRequest httpServletRequest,
        final HttpServletResponse httpServletResponse) {
    return process(projectId, applicationId, HttpMethod.PATCH, httpServletRequest, httpServletResponse);
}

From source file:com.angkorteam.framework.swagger.factory.SwaggerFactory.java

@Override
public void afterPropertiesSet() throws Exception {
    Swagger swagger = new Swagger();
    io.swagger.models.Info info = new io.swagger.models.Info();
    swagger.setInfo(info);//from w  ww  .j ava 2s.c  o m
    info.setTitle(title);
    info.setLicense(license);
    info.setContact(contact);
    info.setTermsOfService(termsOfService);
    info.setVersion(version);
    info.setDescription(description);

    swagger.setConsumes(consumes);
    swagger.setProduces(produces);
    swagger.setSchemes(schemes);
    swagger.setBasePath(basePath);
    swagger.setHost(host);
    swagger.setExternalDocs(externalDocs);

    ConfigurationBuilder config = new ConfigurationBuilder();
    Set<String> acceptablePackages = new HashSet<>();

    boolean allowAllPackages = false;

    if (resourcePackages != null && resourcePackages.length > 0) {
        for (String resourcePackage : resourcePackages) {
            if (resourcePackage != null && !"".equals(resourcePackage)) {
                acceptablePackages.add(resourcePackage);
                config.addUrls(ClasspathHelper.forPackage(resourcePackage));
            }
        }
    }

    config.setScanners(new ResourcesScanner(), new TypeAnnotationsScanner(), new SubTypesScanner());

    Reflections reflections = new Reflections(config);
    Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class);

    Set<Class<?>> output = new HashSet<Class<?>>();
    for (Class<?> cls : controllers) {
        if (allowAllPackages) {
            output.add(cls);
        } else {
            for (String pkg : acceptablePackages) {
                if (cls.getPackage().getName().startsWith(pkg)) {
                    output.add(cls);
                }
            }
        }
    }

    Map<String, Path> paths = new HashMap<>();
    swagger.setPaths(paths);
    Map<String, Model> definitions = new HashMap<>();
    swagger.setDefinitions(definitions);
    Stack<Class<?>> modelStack = new Stack<>();
    for (Class<?> controller : controllers) {
        List<String> clazzPaths = new ArrayList<>();
        RequestMapping clazzRequestMapping = controller.getDeclaredAnnotation(RequestMapping.class);
        Api api = controller.getDeclaredAnnotation(Api.class);
        if (clazzRequestMapping != null) {
            clazzPaths = lookPaths(clazzRequestMapping);
        }
        if (clazzPaths.isEmpty()) {
            clazzPaths.add("");
        }
        if (api != null) {
            if (!"".equals(api.description())) {
                for (String name : api.tags()) {
                    if (!"".equals(name)) {
                        io.swagger.models.Tag tag = new io.swagger.models.Tag();
                        tag.setDescription(api.description());
                        tag.setName(name);
                        swagger.addTag(tag);
                    }
                }
            }
        } else {
            io.swagger.models.Tag tag = new io.swagger.models.Tag();
            tag.setDescription("Unknown");
            tag.setName("Unknown");
            swagger.addTag(tag);
        }
        Method[] methods = null;
        try {
            methods = controller.getDeclaredMethods();
        } catch (NoClassDefFoundError e) {
        }
        if (methods != null && methods.length > 0) {
            for (Method method : methods) {
                RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
                ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
                ApiResponses apiResponses = method.getAnnotation(ApiResponses.class);
                ApiHeaders apiHeaders = method.getAnnotation(ApiHeaders.class);
                List<String> methodPaths = new ArrayList<>();
                if (requestMapping != null && apiOperation != null && apiResponses != null) {
                    methodPaths = lookPaths(requestMapping);
                }
                if (methodPaths.isEmpty()) {
                    methodPaths.add("");
                }
                if (requestMapping != null && apiOperation != null && apiResponses != null) {
                    for (String classPath : clazzPaths) {
                        for (String methodPath : methodPaths) {
                            RequestMethod[] requestMethods = requestMapping.method();
                            if (requestMethods == null || requestMethods.length == 0) {
                                requestMethods = RequestMethod.values();
                            }
                            Path path = new Path();
                            paths.put(classPath + methodPath, path);
                            for (RequestMethod requestMethod : requestMethods) {
                                Operation operation = new Operation();
                                operation.setDescription(apiOperation.description());
                                for (String consume : requestMapping.consumes()) {
                                    operation.addConsumes(consume);
                                }
                                for (String produce : requestMapping.produces()) {
                                    operation.addProduces(produce);
                                }
                                if (api != null) {
                                    if (!"".equals(api.description())) {
                                        for (String name : api.tags()) {
                                            if (!"".equals(name)) {
                                                operation.addTag(name);
                                            }
                                        }
                                    }
                                } else {
                                    io.swagger.models.Tag tag = new io.swagger.models.Tag();
                                    operation.addTag("Unknown");
                                }

                                if (requestMethod == RequestMethod.DELETE) {
                                    path.delete(operation);
                                } else if (requestMethod == RequestMethod.GET) {
                                    path.get(operation);
                                } else if (requestMethod == RequestMethod.HEAD) {
                                    path.head(operation);
                                } else if (requestMethod == RequestMethod.OPTIONS) {
                                    path.options(operation);
                                } else if (requestMethod == RequestMethod.PATCH) {
                                    path.patch(operation);
                                } else if (requestMethod == RequestMethod.POST) {
                                    path.post(operation);
                                } else if (requestMethod == RequestMethod.PUT) {
                                    path.put(operation);
                                }

                                if (apiHeaders != null && apiHeaders.value() != null
                                        && apiHeaders.value().length > 0) {
                                    for (ApiHeader header : apiHeaders.value()) {
                                        HeaderParameter parameter = new HeaderParameter();
                                        parameter.setName(header.name());
                                        parameter.setType("string");
                                        parameter.setDescription(header.description());
                                        parameter.setRequired(header.required());
                                        operation.addParameter(parameter);
                                    }
                                }

                                for (Parameter parameter : method.getParameters()) {
                                    PathVariable pathVariable = parameter.getAnnotation(PathVariable.class);
                                    RequestParam requestParam = parameter.getAnnotation(RequestParam.class);
                                    RequestBody requestBody = parameter.getAnnotation(RequestBody.class);
                                    RequestPart requestPart = parameter.getAnnotation(RequestPart.class);
                                    ApiParam apiParam = parameter.getAnnotation(ApiParam.class);
                                    if (apiParam != null && pathVariable != null
                                            && isSimpleScalar(parameter.getType())) {
                                        PathParameter pathParameter = new PathParameter();
                                        pathParameter.setRequired(true);
                                        pathParameter.setDescription(apiParam.description());
                                        pathParameter.setType(lookupType(parameter.getType()));
                                        pathParameter.setFormat(lookupFormat(parameter.getType(), apiParam));
                                        pathParameter.setName(pathVariable.value());
                                        operation.addParameter(pathParameter);
                                        continue;
                                    }

                                    if (requestMethod == RequestMethod.DELETE
                                            || requestMethod == RequestMethod.GET
                                            || requestMethod == RequestMethod.HEAD
                                            || requestMethod == RequestMethod.OPTIONS
                                            || requestMethod == RequestMethod.PATCH
                                            || requestMethod == RequestMethod.PUT) {
                                        if (apiParam != null && requestParam != null
                                                && isSimpleArray(parameter.getType())) {
                                            QueryParameter param = new QueryParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestParam != null
                                                && isSimpleScalar(parameter.getType())) {
                                            QueryParameter param = new QueryParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && parameter.getType() == MultipartFile.class) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(true);
                                            param.setIn("body");
                                            param.setName("body");
                                            param.setType("file");
                                            param.setDescription(apiParam.description());
                                            operation.addConsumes("application/octet-stream");
                                            //                                                BodyParameter param = new BodyParameter();
                                            //                                                param.setRequired(requestBody.required());
                                            //                                                param.setDescription(apiParam.description());
                                            //                                                param.setName("body");
                                            //                                                ModelImpl model = new ModelImpl();
                                            //                                                model.setType("file");
                                            //                                                param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isSimpleArray(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ArrayModel model = new ArrayModel();
                                            StringProperty property = new StringProperty();
                                            property.setType(lookupType(parameter.getType()));
                                            property.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            model.setItems(property);
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isSimpleScalar(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ModelImpl model = new ModelImpl();
                                            model.setType(lookupType(parameter.getType()));
                                            model.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isModelArray(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            ArrayModel model = new ArrayModel();
                                            RefProperty property = new RefProperty();
                                            property.setType(lookupType(parameter.getType()));
                                            property.set$ref("#/definitions/"
                                                    + parameter.getType().getComponentType().getSimpleName());
                                            if (!modelStack.contains(parameter.getType().getComponentType())) {
                                                modelStack.push(parameter.getType().getComponentType());
                                            }
                                            model.setItems(property);
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestBody != null
                                                && isModelScalar(parameter.getType())) {
                                            BodyParameter param = new BodyParameter();
                                            param.setRequired(requestBody.required());
                                            param.setDescription(apiParam.description());
                                            param.setName("body");
                                            RefModel model = new RefModel();
                                            model.set$ref(
                                                    "#/definitions/" + parameter.getType().getSimpleName());
                                            if (!modelStack.contains(parameter.getType())) {
                                                modelStack.push(parameter.getType());
                                            }
                                            param.setSchema(model);
                                            operation.addParameter(param);
                                            continue;
                                        }
                                    } else if (requestMethod == RequestMethod.POST) {
                                        if (apiParam != null && requestParam != null
                                                && isSimpleArray(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestParam != null
                                                && isSimpleScalar(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestParam.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestParam.value())) {
                                                param.setName(requestParam.value());
                                            }
                                            if (!"".equals(requestParam.name())) {
                                                param.setName(requestParam.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestPart != null
                                                && isSimpleArray(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestPart.required());
                                            param.setDescription(apiParam.description());
                                            param.setType("array");
                                            if (!"".equals(requestPart.value())) {
                                                param.setName(requestPart.value());
                                            }
                                            if (!"".equals(requestPart.name())) {
                                                param.setName(requestPart.name());
                                            }
                                            param.setItems(lookupProperty(parameter.getType(), requestParam,
                                                    apiParam));
                                            operation.addParameter(param);
                                            continue;
                                        }
                                        if (apiParam != null && requestPart != null
                                                && isSimpleScalar(parameter.getType())) {
                                            FormParameter param = new FormParameter();
                                            param.setRequired(requestPart.required());
                                            param.setDescription(apiParam.description());
                                            param.setType(lookupType(parameter.getType()));
                                            param.setFormat(lookupFormat(parameter.getType(), apiParam));
                                            if (!"".equals(requestPart.value())) {
                                                param.setName(requestPart.value());
                                            }
                                            if (!"".equals(requestPart.name())) {
                                                param.setName(requestPart.name());
                                            }
                                            operation.addParameter(param);
                                            continue;
                                        }
                                    }
                                }

                                for (ApiResponse apiResponse : apiResponses.value()) {
                                    if (isSimpleScalar(apiResponse.response())) {
                                        if (apiResponse.array()) {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            ArrayProperty property = new ArrayProperty();
                                            property.setItems(
                                                    lookupProperty(apiResponse.response(), apiResponse));
                                            response.setSchema(property);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        } else {
                                            Response response = new Response();
                                            if ("".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            response.setSchema(
                                                    lookupProperty(apiResponse.response(), apiResponse));
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        }
                                    } else if (isModelScalar(apiResponse.response())) {
                                        if (apiResponse.array()) {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            RefProperty property = new RefProperty();
                                            property.set$ref(
                                                    "#/definitions/" + apiResponse.response().getSimpleName());
                                            if (!modelStack.contains(apiResponse.response())) {
                                                modelStack.push(apiResponse.response());
                                            }
                                            ArrayProperty array = new ArrayProperty();
                                            array.setItems(property);
                                            response.setSchema(array);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        } else {
                                            Response response = new Response();
                                            if (!"".equals(apiResponse.description())) {
                                                response.setDescription(
                                                        apiResponse.httpStatus().getReasonPhrase());
                                            } else {
                                                response.setDescription(apiResponse.description());
                                            }
                                            RefProperty property = new RefProperty();
                                            property.set$ref(
                                                    "#/definitions/" + apiResponse.response().getSimpleName());
                                            if (!modelStack.contains(apiResponse.response())) {
                                                modelStack.push(apiResponse.response());
                                            }
                                            response.setSchema(property);
                                            operation.addResponse(
                                                    String.valueOf(apiResponse.httpStatus().value()), response);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    while (!modelStack.isEmpty()) {
        Class<?> scheme = modelStack.pop();
        if (definitions.containsKey(scheme.getSimpleName())) {
            continue;
        }
        java.lang.reflect.Field[] fields = scheme.getDeclaredFields();
        if (fields != null && fields.length > 0) {
            ModelImpl model = new ModelImpl();
            model.setType("object");
            for (Field field : fields) {
                ApiProperty apiProperty = field.getDeclaredAnnotation(ApiProperty.class);
                if (apiProperty != null) {
                    if (apiProperty.array()) {
                        Class<?> type = apiProperty.model();
                        ArrayProperty property = new ArrayProperty();
                        if (isSimpleScalar(type)) {
                            property.setItems(lookupProperty(type, apiProperty));
                        } else if (isModelScalar(type)) {
                            if (!definitions.containsKey(type.getSimpleName())) {
                                modelStack.push(type);
                            }
                            RefProperty ref = new RefProperty();
                            ref.set$ref("#/definitions/" + type.getSimpleName());
                            property.setItems(ref);
                        }
                        model.addProperty(field.getName(), property);
                    } else {
                        Class<?> type = field.getType();
                        if (isSimpleScalar(type)) {
                            model.addProperty(field.getName(), lookupProperty(type, apiProperty));
                        } else if (isModelScalar(type)) {
                            if (!definitions.containsKey(type.getSimpleName())) {
                                modelStack.push(type);
                            }
                            RefProperty ref = new RefProperty();
                            ref.set$ref("#/definitions/" + type.getSimpleName());
                            model.addProperty(field.getName(), ref);
                        }
                    }
                }
            }
            definitions.put(scheme.getSimpleName(), model);
        }
    }

    this.swagger = swagger;
}