-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[csharp][generichost] Implement not required nullable properties (#16810
) * init * fixed read and write * completed changes using latest-nrt sample * fixed all samples * add null check on write, change on exception * resolved conflicts * build samples * added backing property for not required properties * more not required and nullable hanlding improvements * revert sample updates for a merge master * revert sample updates for a merge master * sample build is working, need to remove warnings * fixed warnings in .net 7 with nrt * fixed manual tests * fixed all samples * fix npe * removed debugging lines * revert changes to unused file * removed unused lambdas * fix a serialization bug * make option a hidden property * updated documentation * improved parameter ordering
- Loading branch information
1 parent
2f655f1
commit 7e52992
Showing
490 changed files
with
44,717 additions
and
7,696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...napi-generator/src/main/java/org/openapitools/codegen/templating/mustache/CopyLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 org.openapitools.codegen.templating.mustache; | ||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
|
||
import com.samskivert.mustache.Mustache; | ||
import com.samskivert.mustache.Template.Fragment; | ||
|
||
/** | ||
* Saves template text to be used later. | ||
* | ||
* Register: | ||
* <pre> | ||
* additionalProperties.put("copy", new CopyLambda()); | ||
* </pre> | ||
* | ||
* Use: | ||
* <pre> | ||
* {{#copy}}{{name}}{{/copy}} | ||
* </pre> | ||
*/ | ||
public class CopyLambda implements Mustache.Lambda { | ||
public String savedContent; | ||
|
||
public CopyLambda() { | ||
} | ||
|
||
@Override | ||
public void execute(Fragment fragment, Writer writer) throws IOException { | ||
savedContent = fragment.execute().stripTrailing(); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...api-generator/src/main/java/org/openapitools/codegen/templating/mustache/PasteLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 org.openapitools.codegen.templating.mustache; | ||
|
||
import java.io.IOException; | ||
import java.io.Writer; | ||
|
||
import com.samskivert.mustache.Mustache; | ||
import com.samskivert.mustache.Template.Fragment; | ||
|
||
/** | ||
* Writes text that was previously saved. | ||
* | ||
* Register: | ||
* <pre> | ||
* additionalProperties.put("paste", new PasteLambda(copyLambda, true, true, true, false)); | ||
* </pre> | ||
* | ||
* Use: | ||
* <pre> | ||
* {{#paste}}{{/paste}} | ||
* </pre> | ||
*/ | ||
public class PasteLambda implements Mustache.Lambda { | ||
private final CopyLambda copyLambda; | ||
private final Boolean stripLeading; | ||
private final Boolean stripTrailing; | ||
private final Boolean endWithLineBreak; | ||
private final Boolean clear; | ||
|
||
public PasteLambda(CopyLambda copyLambda, Boolean stripLeading, Boolean stripTrailing, Boolean endWithLineBreak, boolean clear) { | ||
this.copyLambda = copyLambda; | ||
this.stripLeading = stripLeading; | ||
this.stripTrailing = stripTrailing; | ||
this.endWithLineBreak = endWithLineBreak; | ||
this.clear = clear; | ||
} | ||
|
||
@Override | ||
public void execute(Fragment fragment, Writer writer) throws IOException { | ||
String content = this.copyLambda.savedContent; | ||
|
||
if (content == null) { | ||
return; | ||
} | ||
|
||
if (this.stripTrailing){ | ||
content = content.stripTrailing(); | ||
} | ||
if (this.stripLeading) { | ||
content = content.stripLeading(); | ||
} | ||
if (this.endWithLineBreak && !content.endsWith("\n")){ | ||
content = content + "\n"; | ||
} | ||
writer.write(content); | ||
|
||
if (this.clear) { | ||
this.copyLambda.savedContent = null; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
modules/openapi-generator/src/main/resources/csharp/NullConditionalProperty.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}} | ||
{{#lambda.first}}{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} |
Oops, something went wrong.