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

scripts: add openapi checker #568

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdonadoni
Copy link
Member

Copy link
Member

@audrium audrium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works nicely! However, there are some things to consider:

  • Currently, the solution is quite coupled to reana-server. It would be nice to make it more generic so that we could ideally reuse the same script for r-w-c and r-j-c.
  • Right now, the script fetches error codes from the r-w-c spec, which makes the code a bit complex and coupled. Do you think we would lose a lot of accuracy without this feature? Without it, it would be easier to use the script for r-w-c and r-j-c.
  • The code is quite complex, as I mentioned before. I think we could benefit from more comments so that it would be easier to tweak something later.

@mdonadoni
Copy link
Member Author

Currently, the solution is quite coupled to reana-server. It would be nice to make it more generic so that we could ideally reuse the same script for r-w-c and r-j-c.

It is now possible to choose the flask app with the FLASK_APP environment variable (same as the generate_openapi_spec.py script)

Right now, the script fetches error codes from the r-w-c spec, which makes the code a bit complex and coupled. Do you think we would lose a lot of accuracy without this feature? Without it, it would be easier to use the script for r-w-c and r-j-c.

This also depends on what we want this script to do: if we are only interested in checking "integer" status codes (e.g. return ..., 404 or return ..., 502), then we can consider removing the checks regarding rwc to make the code much easier. However, if we plan on adding more checks in the future, then I don't think it's a good idea to remove the ones we already have.

The code is quite complex, as I mentioned before. I think we could benefit from more comments so that it would be easier to tweak something later.

I've thought a bit on how to make the code better, but I am not sure how to achieve that. Do you have any suggestions?

In any case, this is what has improved:

  • more comments
  • removed checker from ViewVisitor, to avoid circular dependencies between Checker and ViewVisitor
  • tried to simplify a bit ViewVisitor, but I don't think it's possible to do much better than this, as in the end it's just a lot of ifs to check whether the AST node we are considering matches the shape we are interested in.

@mdonadoni
Copy link
Member Author

As this was mostly a prototype:

  • What do you think about it?
  • Are the returned error/warnings useful?
  • Are there more checks we should implement?
  • Regarding the checks that are already implemented, are they working well enough or do you think that there can be too many false positives/negatives?
  • Should we change approach (e.g. do not use AST but something else)?

Finally, where should we put this script? In every repo like generate_openapi_spec.py , as part of reana-dev, somewhere else?

Copy link
Member

@audrium audrium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really nice now! I think it's pretty useful already and errors/warnings are clear enough. Since it's already usable for r-w-c, r-s and r-j-c we could simply keep it in reana-dev as we do for reana_benchmark script

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.

create OpenAPI docstring checker WRT possible jsonify statuses
2 participants