NodeJS SDKs can now optionally preserve additional properties returned in the response. This setting can be enabled via Settings > CodeGen Settings
page in the API editor and turning on the Enable Additional Model Properties
flag.
Node.js Circular Dependency Fix
We have changed the structure of the SDK to break cyclic dependencies. Due to this, the following changes have been made:
- Model deserialization logic has moved out from model classes.
- We have added new files
ObjectMapper.js
andModelFactory.js
to the sdk. - Exception handling in
BaseController
has changed to useObjectMapper
. BaseModel
is now being used to assign values to model properties (when model class is directly instantiated)BaseController
is not being exposed by the API Client now.
Please generate your SDK again to get the improved code.
Polymorphic Responses with Discriminator Field
APIMatic Code Generation engine now supports polymorphic responses with the help of a discriminator field.
- Discriminator is a field that is used to differentiate between a parent model and models that inherit from it.
- The response is deserialized into the parent model or one of its child classes by inspecting the discriminator field's value in the response.
- Using a discriminator field, you can build leaner models by not having to build unions of fields needed by a polymorphic response.
Check out the Discriminator documentation to get started.
Adopting AirBnb JS Style Guide and ES6 Primitives
Keeping with our tradition of Continuous Improvement, we are proud to announce a major revamp of NodeJS SDKs!
- Our code now conforms with Airbnb's JavaScript Style Guide.
- We are using ES6 classes, along with other ES6 primitives.
- You can run
npm run lint
to lint your code immediately. - We generate CI/CD files for Travis, CircleCi, Appveyor and Jenkins to run NodeJS tests.
Please generate your SDK again if you want the improved ES6 based code.
Optional Model Field Deserialization Issue
There was an issue in code generation for PHP SDKs where the model classes (custom types) had fields with incorrect
PHP typehints. This lead to the JsonMapper
mapping responses incorrectly to models during deserialization. However, this
only occurred when a model had fields that were described as optional in the API description and no default value was provided.
Re-generate your PHP SDK to get the fix.
Added Support for Swagger 1.2 ZIP Files
If you have a Swagger 1.2 API description file split into Resource Listing and API Declaration files, you can import/convert it using a ZIP file. Previously, such API description file could only be converted/imported by providing the Resource Listing file via a URL where all API Declaration files were located relative to this URL.
Array Serialization Formats
Multiple formats are now supported for Array serialisation in form and query parameters. Formats supported include UnIndexed
, Indexed
, Plain
, CSV
, PSV
, TSV
.
This settings can be set using our API Blueprint CodeGen setting extension named ARRAYSERIALIZATION
.
Added Swagger Type Discriminator Support
Swagger makes use of a property discriminator
to support polymorphism in custom types. We have now added support for this property in our system. We also offer an extension that will allow you to specify a custom value for the discriminator to override its default value.
Multiple Bug Fixes for Node SDK
Multiple bugs were identified and fixed for Node SDK. A summary of all bugs is given below with some details about each:
- There was a bug in printing multi-line string literals in controller files.
- In Controller files, string encoding for headers had some issues.
- Exception Class imports within Controllers were printed with invalid exception class names.
- Moment.js (for Date/Datetime) import statement was not being handled properly.
- Imports for
Server.js
andEnvironment.js
file inindex.js
will now only be included if multiple base urls are specified in the API description. - Exception Class files' constructor function code has improved.
- API Exception's constructor function code has improved.
- Models or model properties which are being used in endpoints (such as parameters) are now being imported properly in the Controllers. Transitive imports are handled as well (if one model requires another, both are included in the controller).
- Custom Type imports in model files have also been fixed now. If a custom type inherits from another custom type or contains an object of another custom type, that custom type is included in the model file. This import logic has been fixed.
- Code in the
Request Client
file was not generating properly forSuperagent
client. Code for retries was being added even through retries were not enabled. This bug has been fixed.
All the above mentioned bugs have been fixed. We recommend generating Node SDK again to get all these bug fixes and minor code improvements.
Additional properties now allowed in CSharp
We have now added support for additional properties in models in the CSharp SDK. The additional properties are deserialized and stored in a dictionary inside the model.
This can be enabled via navigating to the Settings > CodeGen Settings
page in the API editor and enabling the Enable Additional Model Properties
flag.