feat: generate ScanAPI spec from OpenAPI#862
Conversation
- Remove black, flake8, isort from dev dependencies - Add ruff as single linter/formatter - Update Makefile: 'make lint' and 'make format' use ruff - Configure ruff in pyproject.toml (matching existing flake8 ignores) - No linting rule changes - same behavior as before
2b51579 to
d1c84df
Compare
d1c84df to
8078b62
Compare
|
It’s really great to see this finally coming to life. Thanks a lot @guites for pushing this forward and taking it on 💜 As you suggested, I focused on reviewing the solution and UX, not the source code itself. At a first glance, the conversion looks solid! No changes suggested there. I do have a small suggestion around the CLI design, though. What do you think about structuring the command like this? scanapi convert <source> <target> <input>Example: scanapi convert openapi scanapi openapi.yamlIn which:
Possible future uses: scanapi convert postman scanapi collection.json
scanapi convert openapi har api.yaml
I like this structure because it’s explicit, predictable, and scales well as new formats are added. For the output, we could reuse the --output-path flag from reports. Making it more generic would allow us to reuse it here and keep the CLI consistent. Just brainstorming future ideas. It could be interesting to automatically generate tests to validate response bodies when they are described in the openapi spec. Happy to hear your thoughts! |
Description
This is a draft implementation for creating a "Skeleton" ScanAPI test suite from OpenAPI v3 spec files (.json or .yaml).
Please note that the code is not yet production ready, as I wanted to draft a solution in order to advance discussion.
Motivation behind this PR?
Increasing ScanAPI adoption by reducing friction is a long going issue (see #814).
This PR attempts to provide a sample script that converts OpenAPI v3 files, which are very popular, into a scanapi.yaml file.
The objective is to give project maintainers a starting point into implementation ScanAPI to their pipelines.
I'm referring to this starting scanapi.yaml file as a skeleton file. The skeleton should include (by running the convertion script once):
Benefits to this approach:
Some downsides:
Example usage
Let's take the Futurama API project as an example. It's swagger documentation can be accessed here: https://futuramaapi.com/swagger#/ .
We can download the OpenAPI spec file (from https://futuramaapi.com/openapi.json) and run the following command:
This would result in the following ScanAPI yaml:
Points of interest:
headersentry withAuthorization: Bearer ${bearer_token}. If we defined thebearer_tokenanywhere on the file, we have working authentication for these endpoints./api/characters/${Character_character_id}) have the path parameter as a variable. This means we can quickly implement this variable in another endpoint.What type of change is this?
Implementation of a new feature.
Checklist
Issue
Closes #<issue_number>