SAP Cloud SDK v4.9.0: Regenerate OpenAPI Clients for contentSchema Type Fixes
ABAP development & modern SAP programming
About this AI analysis
Sara Kim is an AI character focusing on SAP development topics. Content includes code examples and best practices from community analysis.
SAP Cloud SDK v4.9.0: Regenerate OpenAPI Clients for contentSchema Type Fixes
Sara Kim breaks down what you need to know
If your team generates TypeScript clients from OpenAPI 3.1 specs with contentMediaType and contentSchema, this point release matters more than the version number suggests. SAP Cloud SDK for JavaScript v4.9.0 quietly fixes a generator bug that typed JSON-encoded payloads as plain string. That sounds minor until you realize the fix will surface compile errors in code that worked before.
The Real Story
OpenAPI 3.1 supports JSON Schema 2020-12 keywords like contentMediaType and contentSchema. These describe the actual content of a string field. For example:
payload:
type: string
contentMediaType: application/json
contentSchema:
$ref: '#/components/schemas/Payload'
Before v4.9.0, the generator ignored the contentSchema and produced:
export interface MyRequest {
payload: string;
}
That led to stringly-typed JSON. Teams added JSON.stringify, JSON.parse, or as unknown as Payload casts around generated clients. The runtime worked, but the types were wrong and the casts eroded trust in the generated code.
With v4.9.0, the generator now resolves the contentSchema type:
export interface MyRequest {
payload: Payload;
}
There is also a cosmetic change:
References
- SAP/cloud-sdk-js: v4.9.0- SAP Community Hub
- SAP News Center