
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
github.com/faabiosr/openapi-assert
Advanced tools
openapi-assert is a Go package that provides a affordable way to validate http requests and responses data throught OpenAPI Schema Specification (Swagger) and the project was inspired by PHP Swagger Assertions. It has the following features:
OpenAPI Assert requires Go 1.11 or later.
Use go get.
$ go get github.com/faabiosr/openapi-assert
Then import the package into your own code:
import "github.com/faabiosr/openapi-assert"
The package provides methods that allow you to assert raw data using swagger files.
See it in action:
package main
import (
"log"
"net/http"
assert "github.com/faabiosr/openapi-assert"
)
func main() {
doc, err := assert.LoadFromURI("http://petstore.swagger.io/v2/swagger.json")
if err != nil {
log.Fatal(err)
}
assert := assert.New(doc)
log.Println(
assert.RequestMediaType("text/html", "/pet", http.MethodPost),
)
log.Println(
assert.RequestMediaType("image/gif", "/v2/pet", http.MethodPost),
)
}
Asserting http request object using the swagger schema file:
package main
import (
"fmt"
"log"
"net/http"
assert "github.com/faabiosr/openapi-assert"
)
func main() {
doc, err := assert.LoadFromURI("http://petstore.swagger.io/v2/swagger.json")
if err != nil {
log.Fatal(err)
}
assert := assert.New(doc)
http.HandleFunc("/v2/pet", func(w http.ResponseWriter, r *http.Request) {
err := assert.Request(r)
fmt.Fprint(w, err)
})
log.Fatal(
http.ListenAndServe("127.0.0.1:9000", nil),
)
}
Asserting http response object using the swagger schema file:
package main
import (
"log"
"net/http"
assert "github.com/faabiosr/openapi-assert"
)
func main() {
doc, err := assert.LoadFromURI("http://petstore.swagger.io/v2/swagger.json")
if err != nil {
log.Fatal(err)
}
assert := assert.New(doc)
res, err := http.Get("https://petstore.swagger.io/v2/pet/111111422")
if err != nil {
log.Fatal(err)
}
log.Println(assert.Response(res))
}
# Clean up
$ make clean
# Download project dependencies
$ make configure
# Run tests and generates html coverage file
$ make cover
# Format all go files
$ make fmt
# GolangCI-Lint
$ make lint
# Run tests
$make test
This project is released under the MIT licence. See LICENSE for more details.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.