Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mustache templates #96

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Add mustache templates #96

wants to merge 13 commits into from

Conversation

thomasyu888
Copy link
Member

@thomasyu888 thomasyu888 commented Mar 9, 2021

Fixed #95 , linting is slightly an issue. Unfortunately the template doesn't necessarily generate beautifully linted code, but the idea with using the templates is that only code in the openapi_server.core module is ever edited, everything else remains the same from however the generator creates it.

I added openapi_server.controllers/*.py as the list of files for flake8 to ignore

@thomasyu888 thomasyu888 marked this pull request as ready for review March 9, 2021 15:10
@thomasyu888 thomasyu888 self-assigned this Mar 10, 2021
@tschaffter
Copy link
Member

tschaffter commented Mar 10, 2021

@thomasyu888 Below is listed the files created/updated after running npm run generate:server:latest. This is promising as none of the controller functions have been updated (the implementation is already based on the latest specification).

image

@thomasyu888
Copy link
Member Author

thomasyu888 commented Mar 10, 2021

The only difference is VERSION and that is because I use version 5.0.1. I don't use npm to run the generation command, as I installed openapi-generator with homebrew

@tschaffter
Copy link
Member

The only difference is VERSION and that is because I use version 5.0.1. I don't use npm to run the generation command, as I installed openapi-generator with homebrew

I think I remember generating code base with version 5.0.1 specified in the file VERSION. Maybe I forgot to reinstall my npm dependencies in this repository.

@tschaffter
Copy link
Member

tschaffter commented Mar 18, 2021

I'm trying to identify how this PR would affect the update of a tool when a new version of the API specification is available.

  • A nice selling point of the development model that we have started to advertise is that a tool "stub" can be generated using a single command line. However, the structure of the code base generated using 1 command would be different from the structure of a code base that relies on the mustache template. This can lead to confusion and make the documentation murky.

  • We should assume that updating a tool specification means that the mustache template would need to be updated. It would not always be the case but one would need to check anyway. This means that the developer can no longer run the npm script generate:server:latest specified in package.json, unless we could point the command to official mustache templates that we host somewhere. Even if this was possible, we don't want to maintain official mustache template for all the programming languages supported by the OpenAPI Generator.

@thomasyu888 I think that the complexity that comes with adding the mustache templates to the tool examples AND with maintaining/updating these templates may puzzle developers. At this point I'm trying to figure out when is using mustache template a good/bad idea. If the API specification changes often, there is cost as one would need to update the template first, then update the codebase based on the new template. This sounds cumbersome. What is your thought?

@tschaffter tschaffter marked this pull request as draft March 19, 2021 04:40
@tschaffter
Copy link
Member

tschaffter commented Mar 19, 2021

After discussing with @thomasyu888, we identified that using mustache templates simplifies the process of updating a tool when a new tool API specification release is available but comes at the cost of making the development of the initial version of the tool more complex. We consider that it's more important for developers to be able to develop the first version of their tool easily. Therefore, we will put the template on the back burner for now, potentially mentioning them in an "advanced" section of the tutorial.

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.

Minimize the code to review when updating the API server based on a new OpenAPI document
2 participants