Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda