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

remove api-contract-validator for OpenAPI testing #5

Merged

Conversation

ThisIsMissEm
Copy link
Contributor

🔗 Linked issue

Per #2, this removes the dependency on api-contract-validator which has numerous security vulnerabilities, along with generally being unmaintained. In an effort to achieve a secure core for Japa, this pull request removes the OpenAPI spec testing functionality and it will be moved into a separate Japa Plugin later.

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

See #2 for the details.

I also noted that several of the assertion messages had changed along with one ts-expect-error no longer being necessary.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Question: where is the documentation to submit a PR to it?

@ThisIsMissEm
Copy link
Contributor Author

ThisIsMissEm commented Dec 3, 2024

If someone wants to setup a @japa/openapi-assertions package or something, I'd be happy to contribute an initial version that's just what was in @japa/assert as to provide people an eventual migration path if they were depending on that functionality.

Feel free to create the repository and I'll base it off the current @japa/assert code. (This isn't functionality I use, so I don't want to become the defacto maintainer of it, I prefer request injection testing)

@ThisIsMissEm ThisIsMissEm changed the title feat: remove api-contract-validator for OpenAPI remove api-contract-validator for OpenAPI testing Dec 3, 2024
@thetutlage
Copy link
Contributor

Thanks for the PR. Here you go for the repo. https://github.com/japa/openapi-assertions

Can we please make the package structure based off this template https://github.com/thetutlage/pkg-template?

Essentially, the starting point could be

git clone repo
cd repo
npx giget@latest gh:thetutlage/pkg-template . --force

@ThisIsMissEm

This comment was marked as outdated.

@ThisIsMissEm
Copy link
Contributor Author

@thetutlage I've now the code written for the extracted OpenAPI assertions, as mentioned, I need at least one file in that repository such that I can fork and do a pull request.

Perhaps use the LICENSE.md file?

# The MIT License

Copyright 2022 Harminder Virk, contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@thetutlage
Copy link
Contributor

Sure. I have just scaffolded the project https://github.com/japa/openapi-assertions

@ThisIsMissEm
Copy link
Contributor Author

And here's the most minimal extraction I could do: japa/openapi-assertions#1

There's a few minor changes:

  • Exposed as openapi on test context instead of on assert
  • Renamed assert.isValidApiResponse to openapi.isValidResponse

@ThisIsMissEm
Copy link
Contributor Author

Documentation PR: japa/japa.dev#26

@thetutlage thetutlage merged commit 75fa56a into japa:develop Dec 13, 2024
6 checks passed
@thetutlage
Copy link
Contributor

Thanks @ThisIsMissEm 👍

thetutlage pushed a commit that referenced this pull request Dec 18, 2024
BREAKING CHANGE: API assertions have been moved to its own package
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