Skip to content

fix: omit unset optional string examples across SDK languages - #2140

Merged
ChiragAgg5k merged 4 commits into
mainfrom
fix/kotlin-optional-examples
Oct 23, 2026
Merged

ChiragAgg5k merged 4 commits into
mainfrom
fix/kotlin-optional-examples

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Generated examples send empty strings for optional string parameters without usable examples. A permissions-only file update consequently submits an empty filename and fails server validation.

The generators now leave these values unset using each SDK’s syntax: undefined in Web/Node/React Native; None in Python; nil in Ruby/Swift/Apple; null in Kotlin/Android/Java, Dart/Flutter, PHP and .NET/Unity. Go omits the functional option, Rust uses None, and REST/GraphQL omit the field or argument. CLI already omits optional flags and is covered by the regression.

Strict example checks also preserve the explicit string "0", numeric zero and false. Required parameters, enum suggestions, explicit nonempty examples and SDK method signatures retain their behavior.

Validation:

  • Shared-fixture regression covers 19 targets, including Java positional arguments and REST multipart fields: 199 assertions across the main and edge cases. The main regression fails against the previous implementation.
  • Full Generation suite: 170 tests, 2,175 assertions, 4 existing skips.
  • PHPCS, targeted PHPStan, Rector and Twig lint passed.
  • Regenerated all SDK targets. Go/CLI, Kotlin/Android, .NET/Unity, Ruby and Rust format checks passed; Web/Node/React Native format, lint and type checks passed. Node’s 160 tests passed.
  • Edge regressions cover nested Python request models and a required REST JSON body whose omitted fields leave {}.
  • Generated Python Black, PHP static analysis, and Swift checks with the installed 6.4 formatter (using a compatible config) also passed. Dart/Flutter source and tests match the pre-fix baseline byte-for-byte; their local formatter differences are pre-existing. The fixture also exposes an existing unused PHP enum import; the required CI toolchains are being monitored.

Found while preparing appwrite/sdk-for-android#146, which will consume the generator patch before Android 31.0.1 is published.

Related: appwrite-labs/cloud#6667

@hansi-codes

hansi-codes Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The generator omits optional string examples that have no usable value across SDK documentation, using each language’s native unset representation while preserving explicit falsy values and required parameters. The change covers language-specific example generation, REST and GraphQL output, and shared regression fixtures for nested models, multipart requests, and empty JSON bodies.

Latest changes: The newest commit adds a required nested Python string without an example to the fixture and asserts that it remains in generated request-model examples.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 19
File Change
src/SDK/Language.php Adds the shared predicate for omitting optional non-enum string examples, with a requiredness override for schema properties.
src/SDK/Language/Dart.php Preserves explicit falsy examples and emits null for omitted optional strings.
src/SDK/Language/DotNet.php Preserves explicit falsy examples and emits null for omitted optional strings.
src/SDK/Language/Go.php Preserves explicit falsy examples while omitting unusable optional string examples.
src/SDK/Language/GraphQL.php Uses strict example-presence checks to retain explicit falsy values.
src/SDK/Language/Kotlin.php Preserves explicit falsy examples and emits null for omitted optional strings.
src/SDK/Language/PHP.php Preserves explicit falsy examples and emits null for omitted optional strings.
src/SDK/Language/Python.php Emits None for omitted optional strings and filters optional string fields from nested request-model examples using requiredness.
src/SDK/Language/REST.php Uses strict example-presence checks to retain explicit falsy values.
src/SDK/Language/Ruby.php Preserves explicit falsy examples and emits nil for omitted optional strings.
src/SDK/Language/Rust.php Preserves explicit falsy examples and renders omitted optional strings as None in documentation calls.
src/SDK/Language/Swift.php Preserves explicit falsy examples and emits nil for omitted optional strings.
src/SDK/Language/Web.php Preserves explicit falsy examples and emits undefined for omitted optional strings.
src/SDK/SDK.php Registers the shared omission predicate as a Twig filter for generated documentation.
templates/go/docs/example.md.twig Omits unset optional strings from Go documentation calls and file-package detection.
templates/graphql/docs/example.md.twig Filters unset optional arguments from GraphQL operations, variables, and multipart file mappings.
templates/rest/docs/example.md.twig Filters unset optional values and retains an empty JSON object when all body properties are omitted.
tests/generation/GenerationTest.php Adds cross-target omission and falsy-value assertions, including required nested Python fields and empty REST bodies.
tests/resources/spec-openapi3.json Adds fixture cases for absent, empty, falsy, required, and multipart examples.
✅ Fixed since the last review · 1
  • Test required nested strings without examples · src/SDK/Language/Python.php:550

Reviewed the commits since c3d3165 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 23, 2026

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · See the inline comments. Summary

Comment thread src/SDK/Language/Kotlin.php Outdated
@ChiragAgg5k ChiragAgg5k changed the title fix(kotlin): omit optional strings without example values fix: omit unset optional string examples across SDK languages Oct 23, 2026

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread src/SDK/Language/Python.php

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit ab26aa0 into main Oct 23, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant