-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #914 from k1LoW/fix-panic
Fix panics caused by ResponseContentTypeNotFound in the case of a response with a range status code.
- Loading branch information
Showing
65 changed files
with
18,071 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tmpmod/github.com/pb33f/libopenapi-validator/.github/workflows/build.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.21 | ||
id: go | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
if [ -f Gopkg.toml ]; then | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
dep ensure | ||
fi | ||
- name: Test | ||
run: go test ./... | ||
- name: Coverage | ||
run: | | ||
go get github.com/axw/gocov/gocov | ||
go get github.com/AlekSi/gocov-xml | ||
go install github.com/axw/gocov/gocov | ||
go install github.com/AlekSi/gocov-xml | ||
- run: | | ||
go test -v -coverprofile cover.out ./... | ||
gocov convert cover.out | gocov-xml > coverage.xml | ||
- uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml | ||
flags: unittests | ||
fail_ci_if_error: false | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Use github.com/k1LoW/libopenapi-validator@support-4xx-or-5xx-responce-content-type-not-found (e3c620ad83a236ecf761fc6d8f86b562b7eda22b) as github.com/k1LoW/runn/tmpmod/github.com/pb33f/libopenapi-validator temporarily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MIT License | ||
|
||
libopenapi-validator | ||
|
||
Copyright (c) 2023 Princess Beef Heavy Industries, LLC & Dave Shanley | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<p align="center"> | ||
<img src="libopenapi-logo.png" alt="libopenapi" height="300px" width="450px"/> | ||
</p> | ||
|
||
# Enterprise grade OpenAPI validation tools for golang. | ||
|
||
![Pipeline](https://github.com/pb33f/libopenapi-validator/workflows/Build/badge.svg) | ||
[![codecov](https://codecov.io/gh/pb33f/libopenapi-validator/branch/main/graph/badge.svg?)](https://codecov.io/gh/pb33f/libopenapi-validator) | ||
[![discord](https://img.shields.io/discord/923258363540815912)](https://discord.gg/x7VACVuEGP) | ||
[![Docs](https://img.shields.io/badge/godoc-reference-5fafd7)](https://pkg.go.dev/github.com/pb33f/libopenapi-validator) | ||
|
||
A validation module for [libopenapi](https://github.com/pb33f/libopenapi). | ||
|
||
`libopenapi-validator` will validate the following elements against an OpenAPI 3+ specification | ||
|
||
- *http.Request* - Validates the request against the OpenAPI specification | ||
- *http.Response* - Validates the response against the OpenAPI specification | ||
- *libopenapi.Document* - Validates the OpenAPI document against the OpenAPI specification | ||
- *base.Schema* - Validates a schema against a JSON or YAML blob / unmarshalled object | ||
|
||
👉👉 [Check out the full documentation](https://pb33f.io/libopenapi/validation/) 👈👈 | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
```bash | ||
go get github.com/pb33f/libopenapi-validator | ||
``` | ||
|
||
## Documentation | ||
|
||
- [The structure of the validator](https://pb33f.io/libopenapi/validation/#the-structure-of-the-validator) | ||
- [Validation errors](https://pb33f.io/libopenapi/validation/#validation-errors) | ||
- [Schema errors](https://pb33f.io/libopenapi/validation/#schema-errors) | ||
- [High-level validation](https://pb33f.io/libopenapi/validation/#high-level-validation) | ||
- [Validating http.Request](https://pb33f.io/libopenapi/validation/#validating-httprequest) | ||
- [Validating http.Request and http.Response](https://pb33f.io/libopenapi/validation/#validating-httprequest-and-httpresponse) | ||
- [Validating just http.Response](https://pb33f.io/libopenapi/validation/#validating-just-httpresponse) | ||
- [Validating HTTP Parameters](https://pb33f.io/libopenapi/validation/#validating-http-parameters) | ||
- [Validating an OpenAPI document](https://pb33f.io/libopenapi/validation/#validating-an-openapi-document) | ||
- [Validating Schemas](https://pb33f.io/libopenapi/validation/#validating-schemas) | ||
|
||
[libopenapi](https://github.com/pb33f/libopenapi) and [libopenapi-validator](https://github.com/pb33f/libopenapi-validator) are | ||
products of Princess Beef Heavy Industries, LLC |
16 changes: 16 additions & 0 deletions
16
tmpmod/github.com/pb33f/libopenapi-validator/errors/error_utilities.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package errors | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
// PopulateValidationErrors mutates the provided validation errors with additional useful error information, that is | ||
// not necessarily available when the ValidationError was created and are standard for all errors. | ||
// Specifically, the RequestPath, SpecPath and RequestMethod are populated. | ||
func PopulateValidationErrors(validationErrors []*ValidationError, request *http.Request, path string) { | ||
for _, validationError := range validationErrors { | ||
validationError.SpecPath = path | ||
validationError.RequestMethod = request.Method | ||
validationError.RequestPath = request.URL.Path | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tmpmod/github.com/pb33f/libopenapi-validator/errors/package.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley | ||
// SPDX-License-Identifier: MIT | ||
|
||
// Package errors contains all the error types used by the validator | ||
package errors |
Oops, something went wrong.