Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda