Skip to content

Use unescaped path in server stub templates #5157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ import javax.ws.rs.*;
import javax.validation.constraints.*;
{{/useBeanValidation}}

@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();

{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import java.util.List;
{{#useBeanValidation}}
import javax.validation.constraints.*;
{{/useBeanValidation}}
@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
@RequestScoped

@Api(description = "the {{baseName}} API")
@Api(description = "the {{{baseName}}} API")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{>generatedAnnotation}}
Expand All @@ -39,7 +39,7 @@ public class {{classname}} {
{{#operation}}

@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface {{classname}} {
{{#operation}}

@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} })
{{/hasConsumes}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class {{classname}}Test {
api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", {{classname}}.class, providers);
{{/generateSpringBootApplication}}
{{^generateSpringBootApplication}}
api = JAXRSClientFactory.create("{{basePath}}", {{classname}}.class, providers);
api = JAXRSClientFactory.create("{{{basePath}}}", {{classname}}.class, providers);
{{/generateSpringBootApplication}}
org.apache.cxf.jaxrs.client.Client client = WebClient.client(api);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;

@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();

{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>{{basePath}}</param-value>
<param-value>{{{basePath}}}</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ import javax.validation.constraints.*;
{{/useBeanValidation}}
{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
{{/isMultipart}}{{/operation}}{{/operations}}
@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}();

{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import javax.validation.constraints.*;
{{/useBeanValidation}}
{{#operations}}{{#operation}}{{#isMultipart}}import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
{{/isMultipart}}{{/operation}}{{/operations}}
@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{>generatedAnnotation}}
{{#operations}}
public interface {{classname}} {

{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import java.util.List;
import javax.validation.constraints.*;
{{/useBeanValidation}}

@Path("/{{baseName}}")
@Path("/{{{baseName}}}")

@Api(description = "the {{baseName}} API")
@Api(description = "the {{{baseName}}} API")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{>generatedAnnotation}}
Expand All @@ -25,7 +25,7 @@ public class {{classname}} {
{{#operation}}

@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>{{basePath}}</param-value>
<param-value>{{{basePath}}}</param-value>
</init-param>

<load-on-startup>2</load-on-startup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GET /api controllers.ApiDocController.api
#Functions for {{{baseName}}} API
{{#operations}}
{{#operation}}
{{httpMethod}} {{contextPath}}{{path}} controllers.{{classname}}Controller.{{operationId}}({{#pathParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
{{httpMethod}} {{{contextPath}}}{{{path}}} controllers.{{classname}}Controller.{{operationId}}({{#pathParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
{{/operation}}
{{/operations}}
{{/apis}}
Expand Down
4 changes: 2 additions & 2 deletions modules/swagger-codegen/src/main/resources/MSF4J/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;

@Path("/{{baseName}}")
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.Api(description = "the {{baseName}} API")
Expand All @@ -34,7 +34,7 @@ public class {{classname}} {

{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>{{basePath}}</param-value>
<param-value>{{{basePath}}}</param-value>
</init-param>

<load-on-startup>2</load-on-startup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace {{packageName}}.Controllers
/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}{{#responses}}
/// <response code="{{code}}">{{message}}</response>{{/responses}}
[{{httpMethod}}]
[Route("{{basePathWithoutHost}}{{path}}")]
[Route("{{{basePathWithoutHost}}}{{{path}}}")]
[SwaggerOperation("{{operationId}}")]{{#returnType}}
[SwaggerResponse(200, type: typeof({{&returnType}}))]{{/returnType}}
public virtual {{#returnType}}IActionResult{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ group_paths() ->
get_operations() ->
#{ {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
'{{operationId}}' => #{
path => "{{basePathWithoutHost}}{{path}}",
path => "{{{basePathWithoutHost}}}{{{path}}}",
method => <<"{{httpMethod}}">>,
handler => '{{classname}}'
}{{#hasMore}},{{/hasMore}}{{/operation}}{{#hasMore}},{{/hasMore}}{{/operations}}{{/apis}}{{/apiInfo}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class {{#operations}}Test{{classname}}(BaseTestCase):
{{#formParams}}
{{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}}
{{/formParams}}
response = self.client.open('{{#contextPath}}{{.}}{{/contextPath}}{{path}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
response = self.client.open('{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
method='{{httpMethod}}'{{#bodyParam}},
data=json.dumps({{paramName}}){{^consumes}},
content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#-first}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ var routes = Routes{
Route{
"Index",
"GET",
"{{basePathWithoutHost}}/",
"{{{basePathWithoutHost}}}/",
Index,
},
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
Route{
"{{operationId}}",
"{{httpMethod}}",
"{{basePathWithoutHost}}{{path}}",
"{{{basePathWithoutHost}}}{{{path}}}",
{{operationId}},
},
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ $app->get('/', function () use ($app) {
{{#operations}}
{{#operation}}
/**
* {{httpMethod}} {{nickname}}
* {{httpMethod}} {{operationId}}
* Summary: {{summary}}
* Notes: {{notes}}
{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
$app->{{httpMethod}}('{{basePathWithoutHost}}{{path}}', '{{classname}}@{{operationId}}');
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
{{/operation}}
{{/operations}}
{{/apis}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace {{packageName}}.{{packageContext}}.Modules
/// Sets up HTTP methods mappings.
/// </summary>
/// <param name="service">Service handling requests</param>
public {{classname}}Module({{classname}}Service service) : base("{{baseContext}}")
public {{classname}}Module({{classname}}Service service) : base("{{{baseContext}}}")
{ {{#operation}}
{{httpMethod}}["{{path}}"] = parameters =>
{{httpMethod}}["{{{path}}}"] = parameters =>
{
{{#allParams}}{{#isBodyParam}}var {{paramName}} = this.Bind<{{&dataType}}>();{{/isBodyParam}}{{^isBodyParam}}{{#isEnum}}var {{paramName}} = Parameters.ValueOf<{{>innerApiEnumName}}?>({{>innerParameterValueOfArgs}});{{/isEnum}}{{^isEnum}}var {{paramName}} = Parameters.ValueOf<{{&dataType}}>({{>innerParameterValueOfArgs}});{{/isEnum}}{{#hasMore}}
{{/hasMore}}{{/isBodyParam}}{{/allParams}}{{#allParams}}{{#required}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $app = new Silex\Application();
{{#operations}}
{{#operation}}

$app->{{httpMethod}}('{{basePathWithoutHost}}{{path}}', function(Application $app, Request $request{{#pathParams}}, ${{baseName}}{{/pathParams}}) {
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', function(Application $app, Request $request{{#pathParams}}, ${{baseName}}{{/pathParams}}) {
{{#queryParams}}
${{paramName}} = $request->get('{{paramName}}');
{{/queryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ require 'json'
{{#operations}}
{{#operation}}

MyApp.add_route('{{httpMethod}}', '{{basePathWithoutHost}}{{path}}', {
"resourcePath" => "/{{baseName}}",
MyApp.add_route('{{httpMethod}}', '{{{basePathWithoutHost}}}{{{path}}}', {
"resourcePath" => "/{{{baseName}}}",
"summary" => "{{{summary}}}",
"nickname" => "{{nickname}}",
"responseClass" => "{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}",
"endpoint" => "{{path}}",
"endpoint" => "{{{path}}}",
"notes" => "{{{notes}}}",
"parameters" => [
{{#queryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $app = new Slim\App();
* Notes: {{notes}}
{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
*/
$app->{{httpMethod}}('{{basePathWithoutHost}}{{path}}', function($request, $response, $args) {
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', function($request, $response, $args) {
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PathHandlerProvider implements HandlerProvider {
{{#operations}}
{{#operation}}

.add(Methods.{{httpMethod}}, "{{basePathWithoutHost}}{{path}}", new HttpHandler() {
.add(Methods.{{httpMethod}}, "{{{basePathWithoutHost}}}{{{path}}}", new HttpHandler() {
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseSender().send("{{operationId}}");
}
Expand Down