simonireilly / compeller

A strong typescript binding for your OpenAPI Schema that doesn't need generation and is not prescriptive in coding style
MIT License
22 stars 1 forks source link

feat: Add CLI for compeller `add` to support path, method based construction of the schema #42

Open simonireilly opened 2 years ago

simonireilly commented 2 years ago

This PR introduces:

yarn compeller add createUser --path /v1/user --method post

A command for injection of a new path with an associated schema.

The injection will ultimately lead to requiring expansion, to support the full API, and this will be problematic, as we are currently only allowing path and method.

The suggestion would be to enable for a fast MVP creation of common scenarios.

Resource

Assumes something like a rails resource for a restful model

yarn compeller resource v1/users

Which adds opinionated JSON return types for the path:

And would create a schema for NewUser, User, and potential Users as a list, but this would be coupled to User model.

Todo

Justification

Injection can provide rapid development of the JSON schema, whilst also enforcing a convention.

If the convention is sensible, and idiomatic for example, just by building a folder structure, that mirrors the OpenAPI specification, then users will lean into it.

Is this open for extension?

Yes, injection/generation allows full flexibility, think of rails routes, or active model