Skip to content

Commit d47fabb

Browse files
mridangclaude
andcommitted
fix: cross-language parity, allowEmptyValue handling, and CI fixes
- Standardize allowEmptyValue handling across all 12 languages - Fix Content-Type case-insensitive lookup in all templates - Add per-scheme authenticator templates and generated output - Fix Python linting (unused imports) and typecheck (null guards) - Fix Ruby linting (NegatedIfElseCondition, BlockLength, complexity) - Fix Ruby typecheck (RBS signature for sanitize_for_serialization) - Fix Node typecheck (null assertions, filter null from arrays) - Fix PHP static analysis (remove always-true null checks) - Fix PHP formatting (line length in DefaultApiClient) - Fix Java static analysis (SpotBugs null pointer warnings) - Harmonize test coverage across all language targets - Remove non-existent FindPetsByTags tests from Go/Rust/Elixir Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4b69063 commit d47fabb

898 files changed

Lines changed: 35135 additions & 17547 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/io/github/mridang/codegen/generators/csharp/BetterCSharpCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ protected void registerAuthSupportingFiles() {
648648
final String filePath =
649649
Path.of(outputFolder, folder, fileName).toString();
650650
writeFile(filePath, code);
651+
postProcessFile(Path.of(filePath).toFile(), "source");
651652
}
652653
}
653654
}

src/main/java/io/github/mridang/codegen/generators/elixir/BetterElixirCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ private String getOAuthSuffix(SecurityScheme scheme) {
658658
}
659659

660660
@SuppressWarnings("StringConcatenationMissingWhitespace")
661+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
662+
value = "IMPROPER_UNICODE",
663+
justification = "Comparing with ASCII-only constants")
661664
private String generateElixirAuthClass(
662665
String schemeName, String className, SecurityScheme scheme) {
663666
final String authModule = moduleName + ".Auth";

src/main/java/io/github/mridang/codegen/generators/go/BetterGoCodegen.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,22 +603,39 @@ public OperationsMap postProcessOperationsWithModels(
603603
(List<CodegenOperation>) operations.get("operation");
604604
if (ops != null) {
605605
boolean hasOsImport = false;
606+
boolean hasJsonImport = false;
607+
boolean hasStringsImport = false;
606608
for (final CodegenOperation op : ops) {
607609
if (op.returnType != null && op.returnType.contains("os.File")) {
608610
hasOsImport = true;
609-
break;
611+
}
612+
if (op.servers != null && !op.servers.isEmpty()) {
613+
hasStringsImport = true;
610614
}
611615
for (final CodegenParameter p : op.allParams) {
612616
if (p.isFile || (p.dataType != null && p.dataType.contains("os.File"))) {
613617
hasOsImport = true;
614-
break;
618+
}
619+
if (p.isQueryParam
620+
&& !p.isDeepObject
621+
&& p.getContent() != null
622+
&& !p.getContent().isEmpty()) {
623+
hasJsonImport = true;
624+
}
625+
if (p.isCookieParam) {
626+
hasStringsImport = true;
615627
}
616628
}
617-
if (hasOsImport) break;
618629
}
619630
if (hasOsImport) {
620631
objs.put("hasOsImport", true);
621632
}
633+
if (hasJsonImport) {
634+
objs.put("hasJsonImport", true);
635+
}
636+
if (hasStringsImport) {
637+
objs.put("hasStringsImport", true);
638+
}
622639
}
623640
}
624641
return objs;
@@ -765,6 +782,9 @@ private String getOAuthSuffix(SecurityScheme scheme) {
765782
}
766783

767784
@SuppressWarnings("StringConcatenationMissingWhitespace")
785+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
786+
value = "IMPROPER_UNICODE",
787+
justification = "Comparing with ASCII-only constants")
768788
private String generateGoAuthClass(
769789
String schemeName, String className, SecurityScheme scheme) {
770790
if (scheme.getType() == SecurityScheme.Type.HTTP) {

src/main/java/io/github/mridang/codegen/generators/node/BetterNodeCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ private String getOAuthSuffix(SecurityScheme scheme) {
839839
}
840840

841841
@SuppressWarnings("StringConcatenationMissingWhitespace")
842+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
843+
value = "IMPROPER_UNICODE",
844+
justification = "Comparing with ASCII-only constants")
842845
private String generateNodeAuthClass(
843846
String schemeName, String className, SecurityScheme scheme) {
844847
if (scheme.getType() == SecurityScheme.Type.HTTP) {

src/main/java/io/github/mridang/codegen/generators/php/BetterPHPCodegen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,6 @@ protected void registerAuthSupportingFiles() {
709709
/** {@inheritDoc} */
710710
@Override
711711
@SuppressWarnings("StringConcatenationMissingWhitespace")
712-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
713-
value = "IMPROPER_UNICODE",
714-
justification = "Comparing with ASCII-only constants")
715712
protected void generatePerSchemeAuthenticators(OpenAPI openAPI) {
716713
if (openAPI.getComponents() == null
717714
|| openAPI.getComponents().getSecuritySchemes() == null) {
@@ -738,6 +735,7 @@ protected void generatePerSchemeAuthenticators(OpenAPI openAPI) {
738735
final String filePath =
739736
Path.of(outputFolder, folder, fileName).toString();
740737
writeFile(filePath, code);
738+
postProcessFile(Path.of(filePath).toFile(), "source");
741739
}
742740
}
743741
}
@@ -756,6 +754,9 @@ private String getPhpOAuthSuffix(SecurityScheme scheme) {
756754
.orElse("");
757755
}
758756

757+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
758+
value = "IMPROPER_UNICODE",
759+
justification = "Comparing with ASCII-only constants")
759760
private String generatePhpAuthClass(
760761
String schemeName, String className, SecurityScheme scheme) {
761762
final String authPkg = invokerPackage + "\\Auth";

src/main/java/io/github/mridang/codegen/generators/python/BetterPythonCodegen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,6 @@ protected void registerAuthSupportingFiles() {
708708
/** {@inheritDoc} */
709709
@Override
710710
@SuppressWarnings("StringConcatenationMissingWhitespace")
711-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
712-
value = "IMPROPER_UNICODE",
713-
justification = "Comparing with ASCII-only constants")
714711
protected void generatePerSchemeAuthenticators(OpenAPI openAPI) {
715712
if (openAPI.getComponents() == null
716713
|| openAPI.getComponents().getSecuritySchemes() == null) {
@@ -757,6 +754,9 @@ private String getPythonOAuthSuffix(SecurityScheme scheme) {
757754
.orElse("");
758755
}
759756

757+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
758+
value = "IMPROPER_UNICODE",
759+
justification = "Comparing with ASCII-only constants")
760760
private String generatePythonAuthClass(
761761
String schemeName, String className, SecurityScheme scheme) {
762762
if (scheme.getType() == SecurityScheme.Type.HTTP) {

src/main/java/io/github/mridang/codegen/generators/ruby/BetterRubyCodegen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,6 @@ protected void registerAuthSupportingFiles() {
612612
/** {@inheritDoc} */
613613
@Override
614614
@SuppressWarnings("StringConcatenationMissingWhitespace")
615-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
616-
value = "IMPROPER_UNICODE",
617-
justification = "Comparing with ASCII-only constants")
618615
protected void generatePerSchemeAuthenticators(OpenAPI openAPI) {
619616
if (openAPI.getComponents() == null
620617
|| openAPI.getComponents().getSecuritySchemes() == null) {
@@ -671,6 +668,9 @@ private String getRubyOAuthSuffix(SecurityScheme scheme) {
671668
.orElse("");
672669
}
673670

671+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
672+
value = "IMPROPER_UNICODE",
673+
justification = "Comparing with ASCII-only constants")
674674
private String generateRubyAuthClass(
675675
String schemeName, String className, SecurityScheme scheme) {
676676
if (scheme.getType() == SecurityScheme.Type.HTTP) {

src/main/java/io/github/mridang/codegen/generators/rust/BetterRustCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ private String getOAuthSuffix(SecurityScheme scheme) {
667667
}
668668

669669
@SuppressWarnings("StringConcatenationMissingWhitespace")
670+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
671+
value = "IMPROPER_UNICODE",
672+
justification = "Comparing with ASCII-only constants")
670673
private String generateRustAuthClass(
671674
String schemeName, String className, SecurityScheme scheme) {
672675
if (scheme.getType() == SecurityScheme.Type.HTTP) {

src/main/resources/templates/csharp/api/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public class {{classname}} : BaseApi
251251
{{/isDeepObject}}
252252
{{^isDeepObject}}
253253
{{#isAllowEmptyValue}}
254-
queryParams["{{baseName}}"] = options?.{{#lambda.pascalcase}}{{paramName}}{{/lambda.pascalcase}} != null
254+
queryParams["{{baseName}}"] = options!.{{#lambda.pascalcase}}{{paramName}}{{/lambda.pascalcase}} != null
255255
? ValueSerializer.SerializeStyled(
256256
"{{baseName}}",
257257
options.{{#lambda.pascalcase}}{{paramName}}{{/lambda.pascalcase}},

src/main/resources/templates/csharp/default_api_client.mustache

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public sealed class DefaultApiClient : IApiClient, IDisposable
144144

145145
if (!mergedHeaders.ContainsKey("Accept-Encoding"))
146146
{
147-
mergedHeaders["Accept-Encoding"] = "gzip, deflate";
147+
mergedHeaders["Accept-Encoding"] = SupportedEncodings();
148148
}
149149

150150
using HttpRequestMessage request = new(new HttpMethod(method), url);
@@ -269,6 +269,20 @@ public sealed class DefaultApiClient : IApiClient, IDisposable
269269
}
270270
}
271271

272+
/// <summary>
273+
/// Returns a comma-separated list of supported content encodings for
274+
/// the Accept-Encoding header.
275+
///
276+
/// Includes gzip and deflate unconditionally. Brotli ("br") is included
277+
/// when <see cref="System.IO.Compression.BrotliStream"/> is available
278+
/// (.NET 6+).
279+
/// </summary>
280+
/// <returns>Comma-separated encoding names.</returns>
281+
private static string SupportedEncodings()
282+
{
283+
return "gzip, deflate, br";
284+
}
285+
272286
/// <inheritdoc/>
273287
public void Dispose()
274288
{

0 commit comments

Comments
 (0)