Listen to this article. Also available on Spotify. Subscribe to PolyAPI Squawk.
A new update to PolyAPI improves the way functions are replicated across environments. Functions can now be replicated along with their associated schemas, making the process more complete and consistent. This change applies to both private and public functions.
When developers copy a function from one environment to another, the related schemas will now be included automatically. This avoids the need to manually recreate or re-link the schemas in the target environment. It also ensures that the structure of data, including arguments and return types, remains intact.
Why Schemas Matter
Schemas in PolyAPI are used to define and enforce the structure of resources and data types. They are similar to JSONSchema definitions and are essential for type safety and documentation. A function without its schemas can be difficult to use correctly, especially in typed environments where SDKs are generated automatically.
Developers can define schemas manually in the PolyAPI web interface or have them generated by training OpenAPI specifications. Once defined, these schemas become reusable objects within a project or organization.
Schemas are stored in a dedicated namespace and can be referenced directly in code. For example, a schema might appear in code as schemas.Oob.Mews.Account
. These definitions provide strong typing in SDKs and help maintain a single source of truth across functions.
Public Function Replication Also Supports Schemas
In addition to private replication, PolyAPI now includes schema support when replicating public functions. This is useful for teams or organizations that share functionality across environments or tenants.
When a developer replicates a public function, any public schemas connected to that function will also be replicated. The replicated schemas retain their visibility settings and appear in the correct namespace within the new environment. This ensures that the function can be used immediately with all required types and data definitions in place.
This improvement simplifies the reuse of functions and reduces the chance of errors from missing or incorrect schema definitions. It also helps maintain consistent typing and structure across environments.
Context from Release 21
This update builds on the schema enhancements introduced in Release 21. In that release, schemas were given their own root namespace and could be marked as public. They also became more accessible through the SDK tree, and their usage in code was improved through fully qualified imports.
With these changes, developers can now define, share, and reuse schemas more effectively. The latest replication update makes this system more useful by ensuring that functions and schemas can be moved together.
Summary
Function replication in PolyAPI now supports copying associated schemas. This applies to both private and public functions. The change improves portability and simplifies reuse by ensuring that all required data structures are included when functions are shared across environments. Developers can use this feature to maintain consistency and reduce setup time when working across projects or with shared APIs.
Do you need help getting started or want to see a demo? Reach out to our team or sign up for Poly to get started.