Skip to content

Commit 4ee96fb

Browse files
committed
docs: Flag raw-OpenAPI reads and parity quirks with TODOs
Add greppable TODO comments at each spot in the durable codegen files that consults the raw OpenAPI spec or reproduces a previous-generator quirk for output parity, so `grep -rn TODO codegen/` surfaces every deferred item: - build-model.ts: type resolution (int/float, unions, inline enums), the reserved-keyword remap, the DeviceProperties force-nullable special case, the errors/warnings `message` override heuristic, the discriminated-union quirks (abstract message, reversed KnownSubType order, Unrecognized fallback), and the object-response never-nullable quirk. - csharp.ts: the x-fern-sdk-group-name reversal for class names and the void-endpoint filter. Comments only; generated output stays byte-identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018oCdmrhyAEX8e9sAFRXZAF
1 parent 27b0967 commit 4ee96fb

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

codegen/lib/build-model.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ import type {
3737

3838
const FALLBACK_TYPE = 'object?'
3939

40-
// C# keywords/identifiers that require remapping (ported verbatim).
40+
// C# keyword/identifier remapping, ported verbatim to preserve the previous
41+
// generator's parameter and property names.
42+
// TODO: Revisit these name workarounds once the generated output is allowed to
43+
// change (e.g. use a verbatim identifier `@event`/`@override` instead).
4144
const reservedKeywordMap: Record<string, string> = { override: 'mustOverride' }
4245
const RESERVED_TOKENS = ['event']
4346

@@ -197,6 +200,13 @@ const buildClass = (
197200
return FALLBACK_TYPE
198201
}
199202

203+
// Resolves the C# type string for a property schema and, as a side effect,
204+
// collects the inline enums, nested object classes, and nested unions it
205+
// spawns. Reads the raw OpenAPI schema (oneOf/allOf/$ref/type/enum/items).
206+
// TODO: Derive parameter and property types from @seamapi/blueprint once the
207+
// generated output is allowed to change. Blueprint collapses the integer type
208+
// into number (losing int vs float), flattens unions differently, and does
209+
// not surface these inline enums, so the raw schema is used here for parity.
200210
const mapSchemaType = (
201211
schema: any,
202212
propertyName: string,
@@ -254,6 +264,9 @@ const buildClass = (
254264
return FALLBACK_TYPE
255265
}
256266
const newClassName = pascalCase(name + pascalCase(propertyName))
267+
// TODO: Remove the hardcoded DeviceProperties special case once the
268+
// generated output is allowed to change. It forces every property on
269+
// that one class nullable/optional purely to match the previous output.
257270
const built = buildClass(
258271
newClassName,
259272
schema as ObjSchema,
@@ -294,6 +307,9 @@ const buildClass = (
294307
!forceNullable
295308

296309
const enumOverride = topLevelEnumOverrides?.[propertyName]
310+
// TODO: Replace this name-based errors/warnings `message` override heuristic
311+
// with a general derivation of common union properties once the generated
312+
// output is allowed to change. It only reproduces the previous output.
297313
const shouldOverrideMessage =
298314
propertyName === 'message' &&
299315
(name.includes('Errors') || name.includes('Warnings')) &&
@@ -346,6 +362,11 @@ const buildUnion = (
346362
)
347363
}
348364

365+
// TODO: Build discriminated unions from @seamapi/blueprint variant metadata
366+
// once the generated output is allowed to change. This reads the raw OpenAPI
367+
// oneOf/discriminator and reproduces the previous generator's quirks: the
368+
// errors/warnings-only abstract `message`, the reversed KnownSubType attribute
369+
// order, and the synthesized Unrecognized fallback subclass.
349370
const discriminator = schema.discriminator.propertyName
350371

351372
const objSchemas = Array.from(
@@ -484,6 +505,11 @@ export const buildApiFile = (
484505
throw new Error('Invalid response type')
485506
}
486507

508+
// TODO: Derive the response type and nullability from
509+
// @seamapi/blueprint endpoint.response once the generated output is allowed
510+
// to change. Only the array element honors `nullable`; a non-array response
511+
// is never marked nullable, reproducing a quirk of the previous generator
512+
// (its nullable flag was misrouted and never applied to object responses).
487513
const returnType = route.isVoid
488514
? undefined
489515
: route.responseArrType

codegen/lib/csharp.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export const csharp = (files: Metalsmith.Files): void => {
4545
if (!route.post) continue
4646
if (!route.post['x-fern-sdk-group-name']) continue
4747

48+
// TODO: Use blueprint route/namespace names once the generated output is
49+
// allowed to change. The class name reverses x-fern-sdk-group-name (e.g.
50+
// ['acs', 'credential_pools'] -> CredentialPoolsAcs), a load-bearing quirk
51+
// of the previous generator that must be preserved for output parity.
4852
const groupNames = [...route.post['x-fern-sdk-group-name']]
4953
groupNames.reverse()
5054
const className = pascalCase(groupNames.join('_'))
@@ -57,6 +61,10 @@ export const csharp = (files: Metalsmith.Files): void => {
5761
response_schema: responseSchema,
5862
} = getParameterAndResponseSchema(route)
5963

64+
// TODO: Determine void vs. returning endpoints from
65+
// @seamapi/blueprint endpoint.response once the generated output is allowed
66+
// to change. This reproduces the previous generator's filter, including its
67+
// `ok`-property and x-response-key special-casing, from the raw OpenAPI.
6068
let isVoid = false
6169
if (!responseObjType && !responseArrType) {
6270
if (

0 commit comments

Comments
 (0)