Skip to content

Conversation

@simonireilly
Copy link
Owner

@simonireilly simonireilly commented Feb 26, 2022

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:

  • get /v1/users with 200 code, 403 code
  • get /v1/users/{id} with 200 code, 404 code, 403 code
  • post /v1/users with 201 code, 422 code, 403 code
  • delete /v1/users/{id} with 204 code, 403 code, 404 code

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

Todo

  • Support injection fully, for existing files
  • Develop a testing methodology for compeller behaviors to enable integration testing of injection
    • For example, repeated running should be idempotent.
    • For example injection into paths with an existing method should be supported.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants