Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Generate JS source code from JS object instance

I'm using openapi-client-axios to generate an axios instance from an open-api specification file. When my app starts, it will request the open-api specification and the library will generate an axios instance from it. Now, i would like to remove the runtime dependency to my open-api specification and save the generated instance instead.

Is there a way to generate a prototype builder from a JS object? I would like to achieve something like this:

generateJSCodeFrom(axiosInstance);

Output.js:

function GeneratedAxiosClient() {
  
}

GeneratedAxiosClient.prototype.getById = function(id) {
  return axios.get("localhost:8080/people", {id});
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are a number of code generators for generating client code from OpenAPI specifications. You can use these at compile or authoring time to generate a client so you do not need to load the OpenAPI specification at runtime. Of course this also means that you have to check your generated client regularly for updates if the API changes.

Some tools that generate OpenAPI clients:

  • https://github.com/OpenAPITools/openapi-generator
  • https://github.com/swagger-api/swagger-codegen
  • https://github.com/RicoSuter/NSwag

There is also a wrapper module on npm for the OpenAPITools one which you could integrate into your JS build process.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!