From 72da3b2c768186dd866c27dc8aa708f802f85186 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 31 Aug 2023 15:22:38 +0800 Subject: [PATCH] fix slash in php gneerator doc/config (#16462) --- .../codegen/templating/mustache/BackSlashLambda.java | 3 ++- .../codegen/templating/mustache/ForwardSlashLambda.java | 5 ++++- .../src/main/resources/php-slim4-server/README.mustache | 6 +++--- .../main/resources/php-slim4-server/phpunit.xml.mustache | 4 ++-- .../main/resources/php-symfony/testing/phpunit.xml.mustache | 6 +++--- .../src/main/resources/php/phpunit.xml.mustache | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/BackSlashLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/BackSlashLambda.java index ca022f55db5..50a10b78999 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/BackSlashLambda.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/BackSlashLambda.java @@ -40,6 +40,7 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; public class BackSlashLambda implements Mustache.Lambda { @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(fragment.execute().replace("/", "\\")); + writer.write(fragment.execute() + .replace("/", "\\")); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/ForwardSlashLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/ForwardSlashLambda.java index 31fde6f95e2..56f903974aa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/ForwardSlashLambda.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/ForwardSlashLambda.java @@ -40,6 +40,9 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; public class ForwardSlashLambda implements Mustache.Lambda { @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(fragment.execute().replace("\\", "/")); + writer.write(fragment.execute() + .replace("\\/", "/") + .replace("\\", "/") + .replace("//", "/")); } } diff --git a/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache b/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache index 4d042902f2b..c0df2c5baa2 100644 --- a/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim4-server/README.mustache @@ -196,17 +196,17 @@ No model defined in this package {{#authMethods}} {{#isBasicBasic}} ### Security schema `{{name}}` -> Important! To make Basic authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{authSrcPath}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\BasicAuthenticator](./src/Auth/BasicAuthenticator.php) class. +> Important! To make Basic authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{#lambda.forwardslash}}{{authSrcPath}}{{/lambda.forwardslash}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\BasicAuthenticator](./src/Auth/BasicAuthenticator.php) class. {{/isBasicBasic}} {{#isApiKey}} ### Security schema `{{name}}` -> Important! To make ApiKey authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{authSrcPath}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\ApiKeyAuthenticator](./src/Auth/ApiKeyAuthenticator.php) class. +> Important! To make ApiKey authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{#lambda.forwardslash}}{{authSrcPath}}{{/lambda.forwardslash}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\ApiKeyAuthenticator](./src/Auth/ApiKeyAuthenticator.php) class. {{/isApiKey}} {{#isOAuth}} ### Security schema `{{name}}` -> Important! To make OAuth authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{authSrcPath}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\OAuthAuthenticator](./src/Auth/OAuthAuthenticator.php) class. +> Important! To make OAuth authentication work you need to extend [\{{authPackage}}\{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}]({{#lambda.forwardslash}}{{authSrcPath}}{{/lambda.forwardslash}}/{{abstractNamePrefix}}Authenticator{{abstractNameSuffix}}.php) class by [\{{authPackage}}\OAuthAuthenticator](./src/Auth/OAuthAuthenticator.php) class. Scope list: {{#scopes}} diff --git a/modules/openapi-generator/src/main/resources/php-slim4-server/phpunit.xml.mustache b/modules/openapi-generator/src/main/resources/php-slim4-server/phpunit.xml.mustache index ce868087865..9f136a95fc4 100644 --- a/modules/openapi-generator/src/main/resources/php-slim4-server/phpunit.xml.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim4-server/phpunit.xml.mustache @@ -2,9 +2,9 @@ - {{apiSrcPath}} + {{#lambda.forwardslash}}{{apiSrcPath}}{{/lambda.forwardslash}} ./{{srcBasePath}}/BaseModel.php - {{modelSrcPath}} + {{#lambda.forwardslash}}{{modelSrcPath}}{{/lambda.forwardslash}} diff --git a/modules/openapi-generator/src/main/resources/php-symfony/testing/phpunit.xml.mustache b/modules/openapi-generator/src/main/resources/php-symfony/testing/phpunit.xml.mustache index 3e3eebd1bff..771c2554b43 100644 --- a/modules/openapi-generator/src/main/resources/php-symfony/testing/phpunit.xml.mustache +++ b/modules/openapi-generator/src/main/resources/php-symfony/testing/phpunit.xml.mustache @@ -9,9 +9,9 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> - {{apiSrcPath}} - {{modelSrcPath}} - {{controllerSrcPath}} + {{#lambda.forwardslash}}{{apiSrcPath}}{{/lambda.forwardslash}} + {{#lambda.forwardslash}}{{modelSrcPath}}{{/lambda.forwardslash}} + {{#lambda.forwardslash}}{{controllerSrcPath}}{{/lambda.forwardslash}} diff --git a/modules/openapi-generator/src/main/resources/php/phpunit.xml.mustache b/modules/openapi-generator/src/main/resources/php/phpunit.xml.mustache index b72fb7c6e77..735a746cae7 100644 --- a/modules/openapi-generator/src/main/resources/php/phpunit.xml.mustache +++ b/modules/openapi-generator/src/main/resources/php/phpunit.xml.mustache @@ -2,8 +2,8 @@ - {{apiSrcPath}} - {{modelSrcPath}} + {{#lambda.forwardslash}}{{apiSrcPath}}{{/lambda.forwardslash}} + {{#lambda.forwardslash}}{{modelSrcPath}}{{/lambda.forwardslash}}