loopbackio / loopbackio/loopback-next

OpenAPI generator use case: recurring vs. one-time

Ouverte
#7,029 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

CLI feature OpenAPI
Langage dominant
TypeScript
Étoiles
5.1k
Forks
1.1k
Merge moyen
2 j 21 h
PR mergées (30 j)
27

Description

## Suggestion

The current [OpenAPI generator](https://loopback.io/doc/en/lb4/OpenAPI-generator.html) 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](https://graphql-code-generator.com/docs/integrations/prettier))
- 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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la documentation liée d’OpenAPI generator et examinez comment LoopBack exécute actuellement le générateur. Comparez ce comportement avec le workflow demandé pour les builds récurrents, notamment les fichiers générés non versionnés, les marqueurs de fichiers générés, le formatage et les retours de TypeScript. La tâche serait terminée lorsqu’une conception approuvée et un moyen pris en charge d’utiliser le générateur depuis les builds de l’application seraient disponibles.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
node.js, openapi, typescript
Domaine
api, backend-api-design
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.