Sunday, December 22, 2024
5.6 C
London

Automation of JSON2APEX – My journey to writing my own automated tooling for this!

Lyrics

Each and every time developing an integration, I wanted to automate the most tedious and routine part of it – creating wrappers for integration entities. I found a couple of tools for it, but all of them are online tools. That meant I had to leave the comfort and speed of automation via command-line and my keyboard, which I did not prefer to do. I used Sublime for a while and tried to find some polygons that would help me, but failed. But, that’s alright – as they say, if you can’t find something that suits your requirements – DIY!

Basic JSON2Apex

Basically, this tool can create an Apex class from a JSON sample, e.g. an API response. How is this any different from online tools, you may ask? Most online tools do not care about having the same attributes in entities and often generate a lot of almost similar classes. Well, when I’m generating a code I want to get rid of manual completely, so I don’t want to look through generated classes to find duplicates. JSON2Apex handles similar properties and generates only one wrapper class for them.

Meta-language

There’s one more feature in the plugin – it allows you to code in a meta-language. This means you can quickly create some kind of an interface for the future class. You describe the whole class in YAML, specifying interfaces it implements and classes it extends, and JSON2Apex generates a class with methods’ notations. So you should only insert implementation.

Creating API

At the time when I started coding this tool, I was working on an API for an Angular app, and we had to document it in Swagger 2.0. Researching the Swagger syntax, I thought that it would be nice to have a tool that would create an API from the description. Unfortunately, I’ve found nothing useful for generating Apex from Swagger, so, once again, I started coding it myself. The work is still in progress, but soon we will generate a Salesforce custom REST resource out of an API description written in Swagger. RAML 1.0 is also in the works!

Try it yourself! – https://packagecontrol.io/packages/JSON2Apex

Hot this week

How to Best Providing Dissertation Writing Services

7 Tips for Choosing the Right Dissertation Topic""Navigating the...

The Wedding Dresses: Finding Your Dream Gown

Choosing a wedding dress is one of the most...

Exploring Bangalore’s Real Estate Boom: A Guide to New and Upcoming Projects

Bangalore is a city that is renowned for its...

12 Ways Edge Servers Accelerate Limitless Growth

As new digital frontiers emerge, businesses pursue growth without...

Lab Grown Diamond Bracelets: The Epitome of Ethical Luxury

In the world of luxury accessories, lab grown diamond...

Topics

How to Best Providing Dissertation Writing Services

7 Tips for Choosing the Right Dissertation Topic""Navigating the...

The Wedding Dresses: Finding Your Dream Gown

Choosing a wedding dress is one of the most...

12 Ways Edge Servers Accelerate Limitless Growth

As new digital frontiers emerge, businesses pursue growth without...

Lab Grown Diamond Bracelets: The Epitome of Ethical Luxury

In the world of luxury accessories, lab grown diamond...

The Essential Guide to Choosing the Right Tax Consultant for Your UAE Business

Navigating the complexities of tax laws in the UAE...

How to Choose the Right Car Tinting Service in Dubai

Car tinting is not just about enhancing the appearance...

Related Articles

Popular Categories