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

create OpenAPI docstring checker WRT possible jsonify statuses #680

Open
tiborsimko opened this issue Dec 1, 2022 · 0 comments · May be fixed by reanahub/reana-server#568
Open

create OpenAPI docstring checker WRT possible jsonify statuses #680

tiborsimko opened this issue Dec 1, 2022 · 0 comments · May be fixed by reanahub/reana-server#568
Assignees

Comments

@tiborsimko
Copy link
Member

Current status

Currently, we have some situations as in r-j-controller's create_job() endpoint returning 403 in some cases:

        try:
            job_obj = job_manager_cls(**job_request)
        except REANAKubernetesMemoryLimitExceeded as e:
            return jsonify({"message": e.message}), 403

However, the 403 response is not documented in create_job()'s docstring:

      responses:
        201:
          description: Request succeeded. The job has been launched.
          schema:
            type: object
            properties:
              job_id:
                type: string
          examples:
            application/json:
              {
                "job_id": "cdcf48b1-c2f3-4693-8230-b066e088c6ac"
              }
        400:
          description: >-
            Request failed. The incoming data specification seems malformed.
        500:
          description: >-
            Request failed. Internal controller error. The job could probably
            not have been allocated.

This means that we don't "advertise" a possible 403 reply to the client of this API, so our API documentation is kind of incomplete.

Expected status

It'll be good to make sure that every jsonify(...), NNN response is well represented in our OpenAPI specs, i.e. in the docstring of each endpoint, so that our OpenAPI could be "complete" towards a future 1.0 release. (Coming after create/validate is moved server-side.)

In order to facilitate discovering these "incomplete" endpoints, it would be good to write a helper function that would:

  • for a component such as r-j-controller, walk through REST blueprint functions;
  • identify jsonify(), NNN responses of the function;
  • check if this NNN response status is well defined in the docstring;
  • if yes, good!
  • if no, warn the developer to add it.

Implementation notes

We could either use some Python AST parsers to help process the code, however even a quick and dirtly regexp matching looking for jsonify() and their locations could be fit for the purpose.

We could plug the newly created OpenAPI checker function into either reana-dev check-openapi -c r-j-controller integration testing CLI, or even to each component run-tests.sh.

@mdonadoni mdonadoni self-assigned this Dec 2, 2022
mdonadoni added a commit to mdonadoni/reana-server that referenced this issue Dec 5, 2022
@mdonadoni mdonadoni linked a pull request Dec 5, 2022 that will close this issue
mdonadoni added a commit to mdonadoni/reana-server that referenced this issue Feb 6, 2023
@audrium audrium self-assigned this Mar 13, 2023
mdonadoni added a commit to mdonadoni/reana-server that referenced this issue May 11, 2023
@mdonadoni mdonadoni added this to 0.95.0 Aug 8, 2024
@mdonadoni mdonadoni moved this to In work in 0.95.0 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In work
Development

Successfully merging a pull request may close this issue.

3 participants