Skip to content

Commit 5954dae

Browse files
authored
[powershell] update doc to use backslash (#16460)
* add backslash, forwardslash lambda * update api doc
1 parent 4a1c70f commit 5954dae

File tree

14 files changed

+175
-82
lines changed

14 files changed

+175
-82
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,13 @@ protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
446446
.put("titlecase", new TitlecaseLambda())
447447
.put("camelcase", new CamelCaseLambda(true).generator(this))
448448
.put("pascalcase", new CamelCaseLambda(false).generator(this))
449+
.put("forwardslash", new ForwardSlashLambda())
450+
.put("backslash", new BackSlashLambda())
449451
.put("indented", new IndentedLambda())
450452
.put("indented_8", new IndentedLambda(8, " ", false))
451453
.put("indented_12", new IndentedLambda(12, " ", false))
452454
.put("indented_16", new IndentedLambda(16, " ", false));
455+
453456
}
454457

455458
private void registerMustacheLambdas() {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343

4444
public class PowerShellClientCodegen extends DefaultCodegen implements CodegenConfig {
4545
private final Logger LOGGER = LoggerFactory.getLogger(PowerShellClientCodegen.class);
46-
4746
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
4847

48+
4949
protected String sourceFolder = "src";
5050
protected String packageName = "PSOpenAPITools";
5151
protected String packageVersion = "0.1.2";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.openapitools.codegen.templating.mustache;
18+
19+
import com.samskivert.mustache.Mustache;
20+
import com.samskivert.mustache.Template;
21+
22+
import java.io.IOException;
23+
import java.io.Writer;
24+
25+
import static org.openapitools.codegen.utils.StringUtils.underscore;
26+
27+
/**
28+
* Replaces forward slash with backslash in the text.
29+
*
30+
* Register:
31+
* <pre>
32+
* additionalProperties.put("backslash", new BackSlashLambda());
33+
* </pre>
34+
*
35+
* Use:
36+
* <pre>
37+
* {{#backslash}}{{summary}}{{/backslash}}
38+
* </pre>
39+
*/
40+
public class BackSlashLambda implements Mustache.Lambda {
41+
@Override
42+
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
43+
writer.write(fragment.execute().replace("/", "\\"));
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.openapitools.codegen.templating.mustache;
18+
19+
import com.samskivert.mustache.Mustache;
20+
import com.samskivert.mustache.Template;
21+
22+
import java.io.IOException;
23+
import java.io.Writer;
24+
25+
import static org.openapitools.codegen.utils.StringUtils.underscore;
26+
27+
/**
28+
* Replaces backslash with forward slash in the text.
29+
*
30+
* Register:
31+
* <pre>
32+
* additionalProperties.put("forwardslash", new ForwardSlashLambda());
33+
* </pre>
34+
*
35+
* Use:
36+
* <pre>
37+
* {{#fforwardslash}}{{summary}}{{/forwardslash}}
38+
* </pre>
39+
*/
40+
public class ForwardSlashLambda implements Mustache.Lambda {
41+
@Override
42+
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
43+
writer.write(fragment.execute().replace("\\", "/"));
44+
}
45+
}

modules/openapi-generator/src/main/resources/powershell/README.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Class | Method | HTTP request | Description
7171
## Documentation for Models
7272

7373
{{#modelPackage}}
74-
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
74+
{{#models}}{{#model}} - [{{#lambda.backslash}}{{{modelPackage}}}{{/lambda.backslash}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
7575
{{/model}}{{/models}}
7676
{{/modelPackage}}
7777
{{^modelPackage}}

modules/openapi-generator/src/main/resources/powershell/api_doc.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# {{packageName}}.{{apiPackage}}.{{classname}}{{#description}}
1+
# {{packageName}}.{{#lambda.backslash}}{{apiPackage}}{{/lambda.backslash}}.{{classname}}{{#description}}
22
{{.}}{{/description}}
33

44
All URIs are relative to *{{{basePath}}}*

samples/client/petstore/powershell/README.md

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -98,78 +98,78 @@ Class | Method | HTTP request | Description
9898

9999
## Documentation for Models
100100

101-
- [PSPetstore/Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
102-
- [PSPetstore/Model.Animal](docs/Animal.md)
103-
- [PSPetstore/Model.ApiResponse](docs/ApiResponse.md)
104-
- [PSPetstore/Model.Apple](docs/Apple.md)
105-
- [PSPetstore/Model.AppleReq](docs/AppleReq.md)
106-
- [PSPetstore/Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
107-
- [PSPetstore/Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
108-
- [PSPetstore/Model.ArrayTest](docs/ArrayTest.md)
109-
- [PSPetstore/Model.Banana](docs/Banana.md)
110-
- [PSPetstore/Model.BananaReq](docs/BananaReq.md)
111-
- [PSPetstore/Model.BasquePig](docs/BasquePig.md)
112-
- [PSPetstore/Model.Capitalization](docs/Capitalization.md)
113-
- [PSPetstore/Model.Cat](docs/Cat.md)
114-
- [PSPetstore/Model.Category](docs/Category.md)
115-
- [PSPetstore/Model.ClassModel](docs/ClassModel.md)
116-
- [PSPetstore/Model.Client](docs/Client.md)
117-
- [PSPetstore/Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
118-
- [PSPetstore/Model.DanishPig](docs/DanishPig.md)
119-
- [PSPetstore/Model.DeprecatedObject](docs/DeprecatedObject.md)
120-
- [PSPetstore/Model.Dog](docs/Dog.md)
121-
- [PSPetstore/Model.Drawing](docs/Drawing.md)
122-
- [PSPetstore/Model.EnumArrays](docs/EnumArrays.md)
123-
- [PSPetstore/Model.EnumTest](docs/EnumTest.md)
124-
- [PSPetstore/Model.EquilateralTriangle](docs/EquilateralTriangle.md)
125-
- [PSPetstore/Model.File](docs/File.md)
126-
- [PSPetstore/Model.FileSchemaTestClass](docs/FileSchemaTestClass.md)
127-
- [PSPetstore/Model.Foo](docs/Foo.md)
128-
- [PSPetstore/Model.FooGetDefaultResponse](docs/FooGetDefaultResponse.md)
129-
- [PSPetstore/Model.FormatTest](docs/FormatTest.md)
130-
- [PSPetstore/Model.Fruit](docs/Fruit.md)
131-
- [PSPetstore/Model.FruitReq](docs/FruitReq.md)
132-
- [PSPetstore/Model.GmFruit](docs/GmFruit.md)
133-
- [PSPetstore/Model.GrandparentAnimal](docs/GrandparentAnimal.md)
134-
- [PSPetstore/Model.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
135-
- [PSPetstore/Model.HealthCheckResult](docs/HealthCheckResult.md)
136-
- [PSPetstore/Model.IsoscelesTriangle](docs/IsoscelesTriangle.md)
137-
- [PSPetstore/Model.List](docs/List.md)
138-
- [PSPetstore/Model.Mammal](docs/Mammal.md)
139-
- [PSPetstore/Model.MapTest](docs/MapTest.md)
140-
- [PSPetstore/Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
141-
- [PSPetstore/Model.Model200Response](docs/Model200Response.md)
142-
- [PSPetstore/Model.ModelReturn](docs/ModelReturn.md)
143-
- [PSPetstore/Model.Name](docs/Name.md)
144-
- [PSPetstore/Model.NullableClass](docs/NullableClass.md)
145-
- [PSPetstore/Model.NullableShape](docs/NullableShape.md)
146-
- [PSPetstore/Model.NumberOnly](docs/NumberOnly.md)
147-
- [PSPetstore/Model.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
148-
- [PSPetstore/Model.Order](docs/Order.md)
149-
- [PSPetstore/Model.OuterComposite](docs/OuterComposite.md)
150-
- [PSPetstore/Model.OuterEnum](docs/OuterEnum.md)
151-
- [PSPetstore/Model.OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
152-
- [PSPetstore/Model.OuterEnumInteger](docs/OuterEnumInteger.md)
153-
- [PSPetstore/Model.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
154-
- [PSPetstore/Model.ParentPet](docs/ParentPet.md)
155-
- [PSPetstore/Model.Pet](docs/Pet.md)
156-
- [PSPetstore/Model.PetWithRequiredTags](docs/PetWithRequiredTags.md)
157-
- [PSPetstore/Model.Pig](docs/Pig.md)
158-
- [PSPetstore/Model.Quadrilateral](docs/Quadrilateral.md)
159-
- [PSPetstore/Model.QuadrilateralInterface](docs/QuadrilateralInterface.md)
160-
- [PSPetstore/Model.ReadOnlyFirst](docs/ReadOnlyFirst.md)
161-
- [PSPetstore/Model.ScaleneTriangle](docs/ScaleneTriangle.md)
162-
- [PSPetstore/Model.Shape](docs/Shape.md)
163-
- [PSPetstore/Model.ShapeInterface](docs/ShapeInterface.md)
164-
- [PSPetstore/Model.ShapeOrNull](docs/ShapeOrNull.md)
165-
- [PSPetstore/Model.SimpleQuadrilateral](docs/SimpleQuadrilateral.md)
166-
- [PSPetstore/Model.SpecialModelName](docs/SpecialModelName.md)
167-
- [PSPetstore/Model.Tag](docs/Tag.md)
168-
- [PSPetstore/Model.Triangle](docs/Triangle.md)
169-
- [PSPetstore/Model.TriangleInterface](docs/TriangleInterface.md)
170-
- [PSPetstore/Model.User](docs/User.md)
171-
- [PSPetstore/Model.Whale](docs/Whale.md)
172-
- [PSPetstore/Model.Zebra](docs/Zebra.md)
101+
- [PSPetstore\Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
102+
- [PSPetstore\Model.Animal](docs/Animal.md)
103+
- [PSPetstore\Model.ApiResponse](docs/ApiResponse.md)
104+
- [PSPetstore\Model.Apple](docs/Apple.md)
105+
- [PSPetstore\Model.AppleReq](docs/AppleReq.md)
106+
- [PSPetstore\Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
107+
- [PSPetstore\Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
108+
- [PSPetstore\Model.ArrayTest](docs/ArrayTest.md)
109+
- [PSPetstore\Model.Banana](docs/Banana.md)
110+
- [PSPetstore\Model.BananaReq](docs/BananaReq.md)
111+
- [PSPetstore\Model.BasquePig](docs/BasquePig.md)
112+
- [PSPetstore\Model.Capitalization](docs/Capitalization.md)
113+
- [PSPetstore\Model.Cat](docs/Cat.md)
114+
- [PSPetstore\Model.Category](docs/Category.md)
115+
- [PSPetstore\Model.ClassModel](docs/ClassModel.md)
116+
- [PSPetstore\Model.Client](docs/Client.md)
117+
- [PSPetstore\Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
118+
- [PSPetstore\Model.DanishPig](docs/DanishPig.md)
119+
- [PSPetstore\Model.DeprecatedObject](docs/DeprecatedObject.md)
120+
- [PSPetstore\Model.Dog](docs/Dog.md)
121+
- [PSPetstore\Model.Drawing](docs/Drawing.md)
122+
- [PSPetstore\Model.EnumArrays](docs/EnumArrays.md)
123+
- [PSPetstore\Model.EnumTest](docs/EnumTest.md)
124+
- [PSPetstore\Model.EquilateralTriangle](docs/EquilateralTriangle.md)
125+
- [PSPetstore\Model.File](docs/File.md)
126+
- [PSPetstore\Model.FileSchemaTestClass](docs/FileSchemaTestClass.md)
127+
- [PSPetstore\Model.Foo](docs/Foo.md)
128+
- [PSPetstore\Model.FooGetDefaultResponse](docs/FooGetDefaultResponse.md)
129+
- [PSPetstore\Model.FormatTest](docs/FormatTest.md)
130+
- [PSPetstore\Model.Fruit](docs/Fruit.md)
131+
- [PSPetstore\Model.FruitReq](docs/FruitReq.md)
132+
- [PSPetstore\Model.GmFruit](docs/GmFruit.md)
133+
- [PSPetstore\Model.GrandparentAnimal](docs/GrandparentAnimal.md)
134+
- [PSPetstore\Model.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
135+
- [PSPetstore\Model.HealthCheckResult](docs/HealthCheckResult.md)
136+
- [PSPetstore\Model.IsoscelesTriangle](docs/IsoscelesTriangle.md)
137+
- [PSPetstore\Model.List](docs/List.md)
138+
- [PSPetstore\Model.Mammal](docs/Mammal.md)
139+
- [PSPetstore\Model.MapTest](docs/MapTest.md)
140+
- [PSPetstore\Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
141+
- [PSPetstore\Model.Model200Response](docs/Model200Response.md)
142+
- [PSPetstore\Model.ModelReturn](docs/ModelReturn.md)
143+
- [PSPetstore\Model.Name](docs/Name.md)
144+
- [PSPetstore\Model.NullableClass](docs/NullableClass.md)
145+
- [PSPetstore\Model.NullableShape](docs/NullableShape.md)
146+
- [PSPetstore\Model.NumberOnly](docs/NumberOnly.md)
147+
- [PSPetstore\Model.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
148+
- [PSPetstore\Model.Order](docs/Order.md)
149+
- [PSPetstore\Model.OuterComposite](docs/OuterComposite.md)
150+
- [PSPetstore\Model.OuterEnum](docs/OuterEnum.md)
151+
- [PSPetstore\Model.OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
152+
- [PSPetstore\Model.OuterEnumInteger](docs/OuterEnumInteger.md)
153+
- [PSPetstore\Model.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
154+
- [PSPetstore\Model.ParentPet](docs/ParentPet.md)
155+
- [PSPetstore\Model.Pet](docs/Pet.md)
156+
- [PSPetstore\Model.PetWithRequiredTags](docs/PetWithRequiredTags.md)
157+
- [PSPetstore\Model.Pig](docs/Pig.md)
158+
- [PSPetstore\Model.Quadrilateral](docs/Quadrilateral.md)
159+
- [PSPetstore\Model.QuadrilateralInterface](docs/QuadrilateralInterface.md)
160+
- [PSPetstore\Model.ReadOnlyFirst](docs/ReadOnlyFirst.md)
161+
- [PSPetstore\Model.ScaleneTriangle](docs/ScaleneTriangle.md)
162+
- [PSPetstore\Model.Shape](docs/Shape.md)
163+
- [PSPetstore\Model.ShapeInterface](docs/ShapeInterface.md)
164+
- [PSPetstore\Model.ShapeOrNull](docs/ShapeOrNull.md)
165+
- [PSPetstore\Model.SimpleQuadrilateral](docs/SimpleQuadrilateral.md)
166+
- [PSPetstore\Model.SpecialModelName](docs/SpecialModelName.md)
167+
- [PSPetstore\Model.Tag](docs/Tag.md)
168+
- [PSPetstore\Model.Triangle](docs/Triangle.md)
169+
- [PSPetstore\Model.TriangleInterface](docs/TriangleInterface.md)
170+
- [PSPetstore\Model.User](docs/User.md)
171+
- [PSPetstore\Model.Whale](docs/Whale.md)
172+
- [PSPetstore\Model.Zebra](docs/Zebra.md)
173173

174174

175175
<a id="documentation-for-authorization"></a>

samples/client/petstore/powershell/docs/PSAnotherFakeApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PSPetstore.PSPetstore/Api.PSAnotherFakeApi
1+
# PSPetstore.PSPetstore\Api.PSAnotherFakeApi
22

33
All URIs are relative to *http://petstore.swagger.io:80/v2*
44

samples/client/petstore/powershell/docs/PSDefaultApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PSPetstore.PSPetstore/Api.PSDefaultApi
1+
# PSPetstore.PSPetstore\Api.PSDefaultApi
22

33
All URIs are relative to *http://petstore.swagger.io:80/v2*
44

samples/client/petstore/powershell/docs/PSFakeApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PSPetstore.PSPetstore/Api.PSFakeApi
1+
# PSPetstore.PSPetstore\Api.PSFakeApi
22

33
All URIs are relative to *http://petstore.swagger.io:80/v2*
44

0 commit comments

Comments
 (0)