Skip to content

docs(sdks): XML-encoded types: text-first child builders (incl. Go xmlTextFirstBuilders), C# indented output, Ruby/PHP declaration aliases, Java varargs - #7586

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1792775258-xml-builder-ergonomics
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1792775258-xml-builder-ergonomics

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The XML model types in Fern SDKs got easier-to-use serialization and builder methods across C#, TypeScript, Java, Go, Ruby, and PHP. This matters to SDK users who build XML documents such as telephony markup: their code gets shorter and reads more naturally. They can pass element text straight to a child builder (response.say("hi"), or r.Say("hi", WithSayVoice("alice")) in Go once they opt in), get indented output in C#, and use familiar method names (asXML(), to_s(false), Body.builder("hi")). Go users also no longer have to build pointer-typed structs by hand to set attributes.

Implements docs for: fix(csharp): XML (TwiML) child builders take text first; ToXml(xmlDeclaration, indent) (fern-api/fern#18418), fix(typescript): XML (TwiML) child builders accept text as a string; quotes not escaped in element text (fern-api/fern#18419), fix(java): XML (TwiML) list-attribute varargs, builder(text) for required text, typed child overloads under legacy names (fern-api/fern#18421), fix(php, ruby): XML (TwiML) asXML() alias and positional to_s(false) (fern-api/fern#18422), fix(go): opt-in xmlTextFirstBuilders for XML (TwiML) child builders (text + functional options) and Ptr[T] helper (fern-api/fern#18430)

Pages changed

I made the same edits to fern/products/sdks/deep-dives/xml-encoded-types.mdx and its legacy copy fern/products/sdks/legacy/deep-dives/xml-encoded-types.mdx:

  • Escaping: element text escapes & < >, and attribute values also escape ".
  • Serialize bullet:
    • Ruby: to_xml(false) and to_s(false) take the declaration flag positionally.
    • PHP: asXML() is an alias for toXml().
    • C#: ToXml(xmlDeclaration, indent) returns indented XML. The other overloads and ToString() stay compact.
  • Build bullet: Java now generates the typed overload under the tag name (Dial.Builder#number(Number)) alongside addNumber(Number), even when a text or attribute setter already uses that name.
  • New paragraph after the bullets on text-first child methods:
    • TypeScript: the child method takes string | Partial<Fields>.
    • C#: parameters run element text first, then required attributes, then optional attributes.
    • Java: types with required text get builder(String text), and list-attribute setters get a varargs overload.
    • Go: opt-in through xmlTextFirstBuilders. With it on, child methods take the text plus With<Type><Attribute> functional options (Say(text, opts ...SayOption), or Pause(opts ...PauseOption) when the element has no text), and the typed method moves to AddSay(*Say). Generated SDKs also get a generic Ptr(v) helper whether or not the option is on.
  • Fixed the TypeScript example: garden.plant("Fern", { sunlight: "full" }) became garden.plant({ name: "Fern", sunlight: "full" }). The generated method takes a single fields?: string | Partial<Fields> argument, so the old two-argument call didn't match it.

fern/products/sdks/legacy/generators/go/configuration.mdx (the generators.yml options page) gets a new xmlTextFirstBuilders ParamField (boolean, default false) with an example, linking to the XML deep dive. I left the sdk-config.yml Go page alone: that schema doesn't map this option.

I checked the signatures against the regenerated seed/*/*-xml-twiml fixtures (including seed/go-sdk/go-xml-twiml/xml-text-first-builders) and the generator source (generators/go/internal/generator/xml.go, generators/go/internal/cmd/cmd.go). pre-commit (vale) and fern check both pass.

… output, Ruby/PHP declaration aliases, Java varargs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

… Ptr helper

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title docs(sdks): XML-encoded types: text-first child builders, C# indented output, Ruby/PHP declaration aliases, Java varargs docs(sdks): XML-encoded types: text-first child builders (incl. Go xmlTextFirstBuilders), C# indented output, Ruby/PHP declaration aliases, Java varargs Oct 24, 2026
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.

0 participants