loopbackio / loopbackio/loopback-next

OpenAPI generator use case: recurring vs. one-time

Abierto
#7,029 1 comentario 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

CLI feature OpenAPI
Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
2 d 21 h
PR fusionados (30 d)
27

Descripción

Suggestion

The current OpenAPI generator seems like it's meant to be used once, upfront, to scaffold code.

My suggestion is to (also/instead) support the use case where you run the generator regularly as part of your build, and don't even check in the generated files. (this is how I generally prefer to use code generators)

Was this considered in the design of the current generator? Is it possible to achieve something like this with LoopBack today?

Details

I'm starting a new project, and I expect to gradually evolve the schema over a couple years. Here's how I want it to work when a developer is updating application code to account for changes in the schema:

  • pull down the new schema
  • run the application build (this runs the code generator, replacing all the generated files)
  • application code that references the generated files now has TypeScript errors, showing you where your attention is needed. (follow the squiggles)

Other desirable properties of code generators:

  • Generated files have a recognizable, git -ignorable ending (e.g. .gen.ts)
  • There's a big scary header comment at the top saying "THIS IS A GENERATED FILE, DO NOT EDIT"
  • Ideally the generated code is formatted, at generation time, according to the project's prettier config. (for example, see graphql-code-generator)
  • You never need to make a change in a generated file. Instead you make changes in the generator's input. (e.g. the OpenAPI schema or in the generator configuration)
  • Because the generated file is unversioned and replaced wholesale, you're never asked to resolve a merge conflict between the new template and your project-specific changes.

Alternatives

  • Is Loopback's OpenAPI generator built on top of other libraries or tools that I might be able to use separately?
  • Do you know of other node.js web frameworks that might align with this philosophy? I don't need all the features loopback provides, I'm just hoping to make my OpenAPI schema the source of truth for endpoint declarations, input/output types, etc.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la documentación enlazada de OpenAPI generator e inspecciona cómo ejecuta actualmente LoopBack el generador. Compara ese comportamiento con el workflow solicitado para builds recurrentes, incluidos los archivos generados sin versionar, los marcadores de archivos generados, el formateo y el feedback de TypeScript. Se consideraría terminado cuando exista un diseño acordado y una forma compatible de usar el generador desde los builds de la aplicación.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
node.js, openapi, typescript
Área
api, backend-api-design
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.