loopbackio / loopbackio/loopback-next

OpenAPI generator use case: recurring vs. one-time

オープン
#7,029 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

CLI feature OpenAPI
主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
2日 21時間
マージ済み PR(30日)
27

説明

## 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされている OpenAPI generator のドキュメントから始め、LoopBack が現在どのように generator を実行しているかを確認します。その動作を、バージョン管理されていない生成ファイル、生成ファイルのマーカー、フォーマット、TypeScript のフィードバックを含む、要求された継続的なビルドの workflow と比較します。合意された設計と、application builds から generator を使用するためのサポートされた方法が必要になります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, openapi, typescript
領域
api, backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。