Custom code regions
Availability
Custom code regions are only available for Enterprise users.
Generally, the Speakeasy code generator “owns” the files it generates. If
modifications are made to them, then the next code generation run will overwrite
any edits that were made. One way to persist modifications to generated files is
to add them to .genignore
, but this has a significant drawback: those files
will stop receiving updates during generation, and thus risk build failures in
the future.
Custom code regions allow developers to add code to specific sections of a generated file that the generator knows to carry forward. Speakeasy can continue to own and update files while providing a constrained way to add bespoke functionality to SDKs.
Syntax
Custom code regions are defined by adding a start and end comments to prescribed sections of a generated file. The comments follow Visual Studio Code’s format for creating code folds (opens in a new tab).
Language support
Custom code regions are currently supported in the following languages: