| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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 {{package}}; |
| |
| {{#imports}} |
| import {{import}}; |
| {{/imports}} |
| |
| import org.apache.polaris.core.resource.TimedApi; |
| |
| import java.util.Map; |
| import java.util.List; |
| |
| import java.io.InputStream; |
| |
| import jakarta.annotation.security.RolesAllowed; |
| |
| import {{javaxPackage}}.ws.rs.Consumes; |
| import {{javaxPackage}}.ws.rs.Produces; |
| import {{javaxPackage}}.ws.rs.DELETE; |
| import {{javaxPackage}}.ws.rs.GET; |
| import {{javaxPackage}}.ws.rs.HEAD; |
| import {{javaxPackage}}.ws.rs.PATCH; |
| import {{javaxPackage}}.ws.rs.POST; |
| import {{javaxPackage}}.ws.rs.PUT; |
| import {{javaxPackage}}.ws.rs.Path; |
| import {{javaxPackage}}.ws.rs.DefaultValue; |
| import {{javaxPackage}}.ws.rs.PathParam; |
| import {{javaxPackage}}.ws.rs.HeaderParam; |
| import {{javaxPackage}}.ws.rs.QueryParam; |
| import {{javaxPackage}}.ws.rs.FormParam; |
| import {{javaxPackage}}.ws.rs.core.Response; |
| import {{javaxPackage}}.servlet.http.HttpServletRequest; |
| import {{javaxPackage}}.servlet.http.HttpServletResponse; |
| import {{javaxPackage}}.ws.rs.core.Context; |
| import {{javaxPackage}}.ws.rs.core.SecurityContext; |
| |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| {{#useBeanValidation}} |
| import {{javaxPackage}}.validation.constraints.*; |
| import {{javaxPackage}}.validation.Valid; |
| {{/useBeanValidation}} |
| {{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; |
| {{/isMultipart}}{{/operation}}{{/operations}} |
| {{! |
| Note that this template is copied /modified from |
| https://github.com/OpenAPITools/openapi-generator/blob/783e68c7acbbdcbb2282d167d1644b069f12d486/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/api.mustache |
| It is updated to remove all swagger annotations |
| }} |
| /** |
| * The {{{baseName}}} API interface |
| * |
| * This file is automatically generated by the OpenAPI Code Generator based on configuration in the |
| * build.gradle file. |
| * |
| */ |
| @Path("{{contextPath}}{{commonPath}}"){{#hasConsumes}} |
| @Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}} |
| @Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}} |
| {{>generatedAnnotation}} |
| {{#operations}} |
| public class {{classname}} { |
| private static final Logger LOGGER = LoggerFactory.getLogger({{classname}}.class); |
| |
| private final {{classname}}Service service; |
| |
| public {{classname}}({{classname}}Service service) { |
| this.service = service; |
| } |
| |
| {{#operation}} |
| /** |
| * {{^notes}}{{{summary}}}{{/notes}}{{{notes}}} |
| * |
| * Response type {@link {{{returnBaseType}}}} |
| *{{#allParams}} @param {{paramName}} {{#required}}Required -{{/required}} {{description}} |
| *{{/allParams}}{{#responses}} |
| * @return {{{code}}} - {{{message}}}{{/responses}} |
| */ |
| @{{httpMethod}}{{#subresourceOperation}} |
| @Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}} |
| @Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}} |
| @Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#hasAuthMethods}} |
| {{#authMethods}}{{#isOAuth}}@RolesAllowed({ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} }){{/isOAuth}}{{/authMethods}}{{/hasAuthMethods}} |
| @TimedApi("{{metricsPrefix}}.{{baseName}}.{{nickname}}") |
| public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{^isMultipart}}{{>formParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}@Context SecurityContext securityContext) { |
| {{! Don't log form or header params in case there are secrets, e.g., OAuth tokens }} |
| LOGGER.atDebug().setMessage("Invoking {{baseName}} with params") |
| .addKeyValue("operation", "{{nickname}}"){{#allParams}}{{^isHeaderParam}}{{^isFormParam}} |
| .addKeyValue("{{paramName}}", {{^isBodyParam}}{{paramName}}{{/isBodyParam}}{{#isBodyParam}}String.valueOf({{paramName}}){{/isBodyParam}}){{/isFormParam}}{{/isHeaderParam}}{{/allParams}} |
| .log(); |
| |
| Response ret = |
| service.{{nickname}}({{#isMultipart}}input,{{/isMultipart}}{{#allParams}}{{^isMultipart}}{{paramName}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}}{{paramName}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}securityContext); |
| LOGGER.debug("Completed execution of {{nickname}} API with status code {}", ret.getStatus()); |
| return ret; |
| } |
| {{/operation}} |
| } |
| {{/operations}} |