Search in sources :

Example 16 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project plumdo-work by wengwh.

the class FormModelResource method updateFormModel.

@ApiOperation(value = "更新表单模型", notes = "根据表单模型的id来指定更新对象,并根据传过来的modelRequest信息来更新表单模型")
@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path"), @ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormModelRequest") })
@RequestMapping(value = "/form-models/{id}", method = RequestMethod.PUT, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public FormModelResponse updateFormModel(@PathVariable Long id, @RequestBody FormModelRequest modelRequest) {
    FormModel formModel = getFormModelFromRequest(id);
    if (modelRequest.getName() != null) {
        formModel.setName(modelRequest.getName());
    }
    if (modelRequest.getKey() != null) {
        formModel.setKey(modelRequest.getKey());
    }
    if (modelRequest.getCategory() != null) {
        formModel.setCategory(modelRequest.getCategory());
    }
    if (modelRequest.getTenantId() != null) {
        formModel.setTenantId(modelRequest.getTenantId());
    }
    formModelRepository.save(formModel);
    return responseFactory.createFormModelResponse(formModel);
}
Also used : FormModel(com.plumdo.form.entity.FormModel) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project plumdo-work by wengwh.

the class FormModelEditorResource method saveEditorJson.

@ApiOperation(value = "保存表单模型设计内容", notes = "根据传入的editorJson来保存表单模型设计内容")
@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path"), @ApiImplicitParam(name = "editorJson", value = "表单模型设计内容", required = true, dataType = "String") })
@RequestMapping(value = "/form-models/{id}/json", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public FormModelResponse saveEditorJson(@PathVariable Long id, @RequestBody String editorJson) throws UnsupportedEncodingException {
    FormModel formModel = getFormModelFromRequest(id);
    formModel.setEditorSourceBytes(editorJson.getBytes("utf-8"));
    formModelRepository.save(formModel);
    return responseFactory.createFormModelResponse(formModel);
}
Also used : FormModel(com.plumdo.form.entity.FormModel) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project incubator-servicecomb-java-chassis by apache.

the class ApiImplicitParamsClassProcessor method process.

@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
    ApiImplicitParams apiImplicitParamsAnnotation = (ApiImplicitParams) annotation;
    ClassAnnotationProcessor processor = swaggerGenerator.getContext().findClassAnnotationProcessor(ApiImplicitParam.class);
    for (ApiImplicitParam paramAnnotation : apiImplicitParamsAnnotation.value()) {
        processor.process(paramAnnotation, swaggerGenerator);
    }
}
Also used : ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ClassAnnotationProcessor(org.apache.servicecomb.swagger.generator.core.ClassAnnotationProcessor) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam)

Example 19 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project incubator-servicecomb-java-chassis by apache.

the class ApiImplicitParamsMethodProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    ApiImplicitParams apiImplicitParamsAnnotation = (ApiImplicitParams) annotation;
    MethodAnnotationProcessor processor = operationGenerator.getContext().findMethodAnnotationProcessor(ApiImplicitParam.class);
    for (ApiImplicitParam paramAnnotation : apiImplicitParamsAnnotation.value()) {
        processor.process(paramAnnotation, operationGenerator);
    }
}
Also used : ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) MethodAnnotationProcessor(org.apache.servicecomb.swagger.generator.core.MethodAnnotationProcessor) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam)

Example 20 with ApiImplicitParams

use of io.swagger.annotations.ApiImplicitParams in project indy by Commonjava.

the class DeprecatedStoreAdminHandler method store.

/*
     * (non-Javadoc)
     * @see org.commonjava.indy.core.rest.admin.DeployPointAdminResource#store(java.lang.String)
     */
@ApiOperation("Update an existing store")
@ApiResponses({ @ApiResponse(code = 200, message = "The store was updated"), @ApiResponse(code = 400, message = "The store specified in the body JSON didn't match the URL parameters") })
@ApiImplicitParams({ @ApiImplicitParam(allowMultiple = false, paramType = "body", name = "body", required = true, dataType = "org.commonjava.indy.model.core.ArtifactStore", value = "The artifact store definition JSON") })
@Path("/{name}")
@PUT
@Consumes(ApplicationContent.application_json)
public Response store(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
    String altPath = Paths.get(MavenPackageTypeDescriptor.MAVEN_ADMIN_REST_BASE_PATH, type, name).toString();
    Consumer<Response.ResponseBuilder> modifier = (rb) -> responseHelper.markDeprecated(rb, altPath);
    final StoreType st = StoreType.get(type);
    Response response = null;
    String json = null;
    try {
        json = IOUtils.toString(request.getInputStream());
        json = objectMapper.patchLegacyStoreJson(json);
    } catch (final IOException e) {
        final String message = "Failed to read " + st.getStoreClass().getSimpleName() + " from request body.";
        logger.error(message, e);
        response = responseHelper.formatResponse(e, message, modifier);
    }
    if (response != null) {
        return response;
    }
    ArtifactStore store = null;
    try {
        store = objectMapper.readValue(json, st.getStoreClass());
    } catch (final IOException e) {
        final String message = "Failed to parse " + st.getStoreClass().getSimpleName() + " from request body.";
        logger.error(message, e);
        response = responseHelper.formatResponse(e, message, modifier);
    }
    if (response != null) {
        return response;
    }
    if (!name.equals(store.getName())) {
        response = responseHelper.markDeprecated(Response.status(Status.BAD_REQUEST).entity(String.format("Store in URL path is: '%s' but in JSON it is: '%s'", name, store.getName())), altPath).build();
    }
    try {
        String user = securityManager.getUser(securityContext, request);
        logger.info("Storing: {}", store);
        if (adminController.store(store, user, false)) {
            response = responseHelper.markDeprecated(ok(), altPath).build();
        } else {
            logger.warn("{} NOT modified!", store);
            response = responseHelper.markDeprecated(notModified(), altPath).build();
        }
    } catch (final IndyWorkflowException e) {
        logger.error(e.getMessage(), e);
        response = responseHelper.formatResponse(e, modifier);
    }
    return response;
}
Also used : Produces(javax.ws.rs.Produces) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) SecurityContext(javax.ws.rs.core.SecurityContext) ApiParam(io.swagger.annotations.ApiParam) StoreListingDTO(org.commonjava.indy.model.core.dto.StoreListingDTO) ApiOperation(io.swagger.annotations.ApiOperation) Consumes(javax.ws.rs.Consumes) Response.noContent(javax.ws.rs.core.Response.noContent) Response.status(javax.ws.rs.core.Response.status) URI(java.net.URI) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) StoreKey(org.commonjava.indy.model.core.StoreKey) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) CONFLICT(javax.ws.rs.core.Response.Status.CONFLICT) StoreType(org.commonjava.indy.model.core.StoreType) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) Response.notModified(javax.ws.rs.core.Response.notModified) IOUtils(org.apache.commons.io.IOUtils) ApplicationContent(org.commonjava.indy.util.ApplicationContent) List(java.util.List) Response(javax.ws.rs.core.Response) Response.ok(javax.ws.rs.core.Response.ok) ApplicationScoped(javax.enterprise.context.ApplicationScoped) UriInfo(javax.ws.rs.core.UriInfo) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) HEAD(javax.ws.rs.HEAD) PathParam(javax.ws.rs.PathParam) REST(org.commonjava.indy.bind.jaxrs.util.REST) GET(javax.ws.rs.GET) ApplicationContent.application_json(org.commonjava.indy.util.ApplicationContent.application_json) JoinString(org.commonjava.atlas.maven.ident.util.JoinString) ApiResponses(io.swagger.annotations.ApiResponses) Inject(javax.inject.Inject) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenPackageTypeDescriptor(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) SecurityManager(org.commonjava.indy.bind.jaxrs.SecurityManager) Api(io.swagger.annotations.Api) Status(javax.ws.rs.core.Response.Status) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) METADATA_CHANGELOG(org.commonjava.indy.model.core.ArtifactStore.METADATA_CHANGELOG) IOException(java.io.IOException) Consumer(java.util.function.Consumer) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) AdminController(org.commonjava.indy.core.ctl.AdminController) PUT(javax.ws.rs.PUT) InputStream(java.io.InputStream) StoreType(org.commonjava.indy.model.core.StoreType) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) JoinString(org.commonjava.atlas.maven.ident.util.JoinString) IOException(java.io.IOException) Path(javax.ws.rs.Path) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Aggregations

ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)29 ApiOperation (io.swagger.annotations.ApiOperation)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 IOException (java.io.IOException)8 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)7 ApiResponses (io.swagger.annotations.ApiResponses)7 Consumes (javax.ws.rs.Consumes)7 Response (javax.ws.rs.core.Response)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)7 ApiResponse (io.swagger.annotations.ApiResponse)6 URI (java.net.URI)6 POST (javax.ws.rs.POST)6 Produces (javax.ws.rs.Produces)5 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)5 PUT (javax.ws.rs.PUT)4 Path (javax.ws.rs.Path)4 Api (io.swagger.annotations.Api)3 ApiParam (io.swagger.annotations.ApiParam)3 PathParameter (io.swagger.models.parameters.PathParameter)3