vendor: update buildkit to v0.29.0-rc1

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2026-03-25 15:47:08 -07:00
parent a7d3578248
commit eba72a35e4
518 changed files with 29223 additions and 24305 deletions
+26
View File
@@ -0,0 +1,26 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
# Set default charset
[*.{js,py,go,scala,rb,java,html,css,less,sass,md}]
charset = utf-8
# Tab indentation (no size specified)
[*.go]
indent_style = tab
[*.md]
trim_trailing_whitespace = false
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
+4 -3
View File
@@ -1,5 +1,6 @@
secrets.yml
coverage.out
coverage.txt
*.out
*.cov
.idea
.env
.mcp.json
.claude/
+14 -19
View File
@@ -2,34 +2,19 @@ version: "2"
linters:
default: all
disable:
- cyclop
- depguard
- errchkjson
- errorlint
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- godot
- godox
- gosmopolitan
- inamedparam
- intrange
- ireturn
- lll
- musttag
- nestif
- gomoddirectives
- exhaustruct
- nlreturn
- noinlineerr
- nonamedreturns
- noinlineerr
- paralleltest
- recvcheck
- testpackage
- thelper
- tparallel
- unparam
- varnamelen
- whitespace
- wrapcheck
@@ -41,8 +26,17 @@ linters:
goconst:
min-len: 2
min-occurrences: 3
cyclop:
max-complexity: 25
gocyclo:
min-complexity: 45
min-complexity: 25
gocognit:
min-complexity: 35
exhaustive:
default-signifies-exhaustive: true
default-case-required: true
lll:
line-length: 180
exclusions:
generated: lax
presets:
@@ -58,6 +52,7 @@ formatters:
enable:
- gofmt
- goimports
- gofumpt
exclusions:
generated: lax
paths:
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+27
View File
@@ -0,0 +1,27 @@
# Contributors
- Repository: ['go-openapi/analysis']
| Total Contributors | Total Contributions |
| --- | --- |
| 15 | 202 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @fredbi | 99 | <https://github.com/go-openapi/analysis/commits?author=fredbi> |
| @casualjim | 70 | <https://github.com/go-openapi/analysis/commits?author=casualjim> |
| @keramix | 9 | <https://github.com/go-openapi/analysis/commits?author=keramix> |
| @youyuanwu | 8 | <https://github.com/go-openapi/analysis/commits?author=youyuanwu> |
| @msample | 3 | <https://github.com/go-openapi/analysis/commits?author=msample> |
| @kul-amr | 3 | <https://github.com/go-openapi/analysis/commits?author=kul-amr> |
| @mbohlool | 2 | <https://github.com/go-openapi/analysis/commits?author=mbohlool> |
| @Copilot | 1 | <https://github.com/go-openapi/analysis/commits?author=Copilot> |
| @danielfbm | 1 | <https://github.com/go-openapi/analysis/commits?author=danielfbm> |
| @gregmarr | 1 | <https://github.com/go-openapi/analysis/commits?author=gregmarr> |
| @guillemj | 1 | <https://github.com/go-openapi/analysis/commits?author=guillemj> |
| @knweiss | 1 | <https://github.com/go-openapi/analysis/commits?author=knweiss> |
| @tklauser | 1 | <https://github.com/go-openapi/analysis/commits?author=tklauser> |
| @cuishuang | 1 | <https://github.com/go-openapi/analysis/commits?author=cuishuang> |
| @ujjwalsh | 1 | <https://github.com/go-openapi/analysis/commits?author=ujjwalsh> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_
+108 -8
View File
@@ -1,22 +1,46 @@
# OpenAPI analysis [![Build Status](https://github.com/go-openapi/analysis/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/analysis/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/analysis)
# analysis
[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/analysis/master/LICENSE)
[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/analysis.svg)](https://pkg.go.dev/github.com/go-openapi/analysis)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/analysis)](https://goreportcard.com/report/github.com/go-openapi/analysis)
<!-- Badges: status -->
[![Tests][test-badge]][test-url] [![Coverage][cov-badge]][cov-url] [![CI vuln scan][vuln-scan-badge]][vuln-scan-url] [![CodeQL][codeql-badge]][codeql-url]
<!-- Badges: release & docker images -->
<!-- Badges: code quality -->
<!-- Badges: license & compliance -->
[![Release][release-badge]][release-url] [![Go Report Card][gocard-badge]][gocard-url] [![CodeFactor Grade][codefactor-badge]][codefactor-url] [![License][license-badge]][license-url]
<!-- Badges: documentation & support -->
<!-- Badges: others & stats -->
[![GoDoc][godoc-badge]][godoc-url] [![Discord Channel][discord-badge]][discord-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
---
A foundational library to analyze an OAI specification document for easier reasoning about the content.
## What's inside?
## Announcements
* **2025-12-19** : new community chat on discord
* a new discord community channel is available to be notified of changes and support users
* our venerable Slack channel remains open, and will be eventually discontinued on **2026-03-31**
You may join the discord community by clicking the invite link on the discord badge (also above). [![Discord Channel][discord-badge]][discord-url]
Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url]
## Status
API is stable.
## Import this library in your project
```cmd
go get github.com/go-openapi/analysis
```
## What's inside
* An analyzer providing methods to walk the functional content of a specification
* A spec flattener producing a self-contained document bundle, while preserving `$ref`s
* A spec merger ("mixin") to merge several spec documents into a primary spec
* A spec "fixer" ensuring that response descriptions are non empty
[Documentation](https://pkg.go.dev/github.com/go-openapi/analysis)
## FAQ
* Does this library support OpenAPI 3?
@@ -25,3 +49,79 @@ A foundational library to analyze an OAI specification document for easier reaso
> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0).
> There is no plan to make it evolve toward supporting OpenAPI 3.x.
> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
## Change log
See <https://github.com/go-openapi/analysis/releases>
<!--
## References
-->
## Licensing
This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE).
<!--
See the license NOTICE, which recalls the licensing terms of all the pieces of software
on top of which it has been built.
-->
<!--
## Limitations
-->
## Other documentation
* [All-time contributors](./CONTRIBUTORS.md)
* [Contributing guidelines](.github/CONTRIBUTING.md)
* [Maintainers documentation](docs/MAINTAINERS.md)
* [Code style](docs/STYLE.md)
## Cutting a new release
Maintainers can cut a new release by either:
* running [this workflow](https://github.com/go-openapi/analysis/actions/workflows/bump-release.yml)
* or pushing a semver tag
* signed tags are preferred
* The tag message is prepended to release notes
<!-- Badges: status -->
[test-badge]: https://github.com/go-openapi/analysis/actions/workflows/go-test.yml/badge.svg
[test-url]: https://github.com/go-openapi/analysis/actions/workflows/go-test.yml
[cov-badge]: https://codecov.io/gh/go-openapi/analysis/branch/master/graph/badge.svg
[cov-url]: https://codecov.io/gh/go-openapi/analysis
[vuln-scan-badge]: https://github.com/go-openapi/analysis/actions/workflows/scanner.yml/badge.svg
[vuln-scan-url]: https://github.com/go-openapi/analysis/actions/workflows/scanner.yml
[codeql-badge]: https://github.com/go-openapi/analysis/actions/workflows/codeql.yml/badge.svg
[codeql-url]: https://github.com/go-openapi/analysis/actions/workflows/codeql.yml
<!-- Badges: release & docker images -->
[release-badge]: https://badge.fury.io/gh/go-openapi%2Fanalysis.svg
[release-url]: https://badge.fury.io/gh/go-openapi%2Fanalysis
<!-- Badges: code quality -->
[gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/analysis
[gocard-url]: https://goreportcard.com/report/github.com/go-openapi/analysis
[codefactor-badge]: https://img.shields.io/codefactor/grade/github/go-openapi/analysis
[codefactor-url]: https://www.codefactor.io/repository/github/go-openapi/analysis
<!-- Badges: documentation & support -->
[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/analysis
[godoc-url]: http://pkg.go.dev/github.com/go-openapi/analysis
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: https://github.com/go-openapi/analysis/?tab=Apache-2.0-1-ov-file#readme
<!-- Badges: others & stats -->
[goversion-badge]: https://img.shields.io/github/go-mod/go-version/go-openapi/analysis
[goversion-url]: https://github.com/go-openapi/analysis/blob/master/go.mod
[top-badge]: https://img.shields.io/github/languages/top/go-openapi/analysis
[commits-badge]: https://img.shields.io/github/commits-since/go-openapi/analysis/latest
+37
View File
@@ -0,0 +1,37 @@
# Security Policy
This policy outlines the commitment and practices of the go-openapi maintainers regarding security.
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 0.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
+38 -38
View File
@@ -164,13 +164,13 @@ func New(doc *spec.Swagger) *Spec {
return a
}
// SecurityRequirement is a representation of a security requirement for an operation
// SecurityRequirement is a representation of a security requirement for an operation.
type SecurityRequirement struct {
Name string
Scopes []string
}
// SecurityRequirementsFor gets the security requirements for the operation
// SecurityRequirementsFor gets the security requirements for the operation.
func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRequirement {
if s.spec.Security == nil && operation.Security == nil {
return nil
@@ -204,7 +204,7 @@ func (s *Spec) SecurityRequirementsFor(operation *spec.Operation) [][]SecurityRe
return result
}
// SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements
// SecurityDefinitionsForRequirements gets the matching security definitions for a set of requirements.
func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequirement) map[string]spec.SecurityScheme {
result := make(map[string]spec.SecurityScheme)
@@ -219,7 +219,7 @@ func (s *Spec) SecurityDefinitionsForRequirements(requirements []SecurityRequire
return result
}
// SecurityDefinitionsFor gets the matching security definitions for a set of requirements
// SecurityDefinitionsFor gets the matching security definitions for a set of requirements.
func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec.SecurityScheme {
requirements := s.SecurityRequirementsFor(operation)
if len(requirements) == 0 {
@@ -250,7 +250,7 @@ func (s *Spec) SecurityDefinitionsFor(operation *spec.Operation) map[string]spec
return result
}
// ConsumesFor gets the mediatypes for the operation
// ConsumesFor gets the mediatypes for the operation.
func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
if len(operation.Consumes) == 0 {
cons := make(map[string]struct{}, len(s.spec.Consumes))
@@ -269,7 +269,7 @@ func (s *Spec) ConsumesFor(operation *spec.Operation) []string {
return s.structMapKeys(cons)
}
// ProducesFor gets the mediatypes for the operation
// ProducesFor gets the mediatypes for the operation.
func (s *Spec) ProducesFor(operation *spec.Operation) []string {
if len(operation.Produces) == 0 {
prod := make(map[string]struct{}, len(s.spec.Produces))
@@ -306,7 +306,7 @@ func fieldNameFromParam(param *spec.Parameter) string {
// whenever an error is encountered while resolving references
// on parameters.
//
// This function takes as input the spec.Parameter which triggered the
// This function takes as input the [spec.Parameter] which triggered the
// error and the error itself.
//
// If the callback function returns false, the calling function should bail.
@@ -329,7 +329,7 @@ func (s *Spec) ParametersFor(operationID string) []spec.Parameter {
// Does not assume parameters properly resolve references or that
// such references actually resolve to a parameter object.
//
// Upon error, invoke a ErrorOnParamFunc callback with the erroneous
// Upon error, invoke a [ErrorOnParamFunc] callback with the erroneous
// parameters. If the callback is set to nil, panics upon errors.
func (s *Spec) SafeParametersFor(operationID string, callmeOnError ErrorOnParamFunc) []spec.Parameter {
gatherParams := func(pi *spec.PathItem, op *spec.Operation) []spec.Parameter {
@@ -337,7 +337,7 @@ func (s *Spec) SafeParametersFor(operationID string, callmeOnError ErrorOnParamF
s.paramsAsMap(pi.Parameters, bag, callmeOnError)
s.paramsAsMap(op.Parameters, bag, callmeOnError)
var res []spec.Parameter
res := make([]spec.Parameter, 0, len(bag))
for _, v := range bag {
res = append(res, v)
}
@@ -388,7 +388,7 @@ func (s *Spec) ParamsFor(method, path string) map[string]spec.Parameter {
// Does not assume parameters properly resolve references or that
// such references actually resolve to a parameter object.
//
// Upon error, invoke a ErrorOnParamFunc callback with the erroneous
// Upon error, invoke a [ErrorOnParamFunc] callback with the erroneous
// parameters. If the callback is set to nil, panics upon errors.
func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc) map[string]spec.Parameter {
res := make(map[string]spec.Parameter)
@@ -400,7 +400,7 @@ func (s *Spec) SafeParamsFor(method, path string, callmeOnError ErrorOnParamFunc
return res
}
// OperationForName gets the operation for the given id
// OperationForName gets the operation for the given id.
func (s *Spec) OperationForName(operationID string) (string, string, *spec.Operation, bool) {
for method, pathItem := range s.operations {
for path, op := range pathItem {
@@ -413,7 +413,7 @@ func (s *Spec) OperationForName(operationID string) (string, string, *spec.Opera
return "", "", nil, false
}
// OperationFor the given method and path
// OperationFor the given method and path.
func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
if mp, ok := s.operations[strings.ToUpper(method)]; ok {
op, fn := mp[path]
@@ -424,12 +424,12 @@ func (s *Spec) OperationFor(method, path string) (*spec.Operation, bool) {
return nil, false
}
// Operations gathers all the operations specified in the spec document
// Operations gathers all the operations specified in the spec document.
func (s *Spec) Operations() map[string]map[string]*spec.Operation {
return s.operations
}
// AllPaths returns all the paths in the swagger spec
// AllPaths returns all the paths in the swagger spec.
func (s *Spec) AllPaths() map[string]spec.PathItem {
if s.spec == nil || s.spec.Paths == nil {
return nil
@@ -438,7 +438,7 @@ func (s *Spec) AllPaths() map[string]spec.PathItem {
return s.spec.Paths.Paths
}
// OperationIDs gets all the operation ids based on method an dpath
// OperationIDs gets all the operation ids based on method an dpath.
func (s *Spec) OperationIDs() []string {
if len(s.operations) == 0 {
return nil
@@ -458,7 +458,7 @@ func (s *Spec) OperationIDs() []string {
return result
}
// OperationMethodPaths gets all the operation ids based on method an dpath
// OperationMethodPaths gets all the operation ids based on method an dpath.
func (s *Spec) OperationMethodPaths() []string {
if len(s.operations) == 0 {
return nil
@@ -474,22 +474,22 @@ func (s *Spec) OperationMethodPaths() []string {
return result
}
// RequiredConsumes gets all the distinct consumes that are specified in the specification document
// RequiredConsumes gets all the distinct consumes that are specified in the specification document.
func (s *Spec) RequiredConsumes() []string {
return s.structMapKeys(s.consumes)
}
// RequiredProduces gets all the distinct produces that are specified in the specification document
// RequiredProduces gets all the distinct produces that are specified in the specification document.
func (s *Spec) RequiredProduces() []string {
return s.structMapKeys(s.produces)
}
// RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec
// RequiredSecuritySchemes gets all the distinct security schemes that are specified in the swagger spec.
func (s *Spec) RequiredSecuritySchemes() []string {
return s.structMapKeys(s.authSchemes)
}
// SchemaRef is a reference to a schema
// SchemaRef is a reference to a schema.
type SchemaRef struct {
Name string
Ref spec.Ref
@@ -498,7 +498,7 @@ type SchemaRef struct {
}
// SchemasWithAllOf returns schema references to all schemas that are defined
// with an allOf key
// with an allOf key.
func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
for _, v := range s.allOfs {
result = append(result, v)
@@ -507,7 +507,7 @@ func (s *Spec) SchemasWithAllOf() (result []SchemaRef) {
return
}
// AllDefinitions returns schema references for all the definitions that were discovered
// AllDefinitions returns schema references for all the definitions that were discovered.
func (s *Spec) AllDefinitions() (result []SchemaRef) {
for _, v := range s.allSchemas {
result = append(result, v)
@@ -516,7 +516,7 @@ func (s *Spec) AllDefinitions() (result []SchemaRef) {
return
}
// AllDefinitionReferences returns json refs for all the discovered schemas
// AllDefinitionReferences returns JSON references for all the discovered schemas.
func (s *Spec) AllDefinitionReferences() (result []string) {
for _, v := range s.references.schemas {
result = append(result, v.String())
@@ -525,7 +525,7 @@ func (s *Spec) AllDefinitionReferences() (result []string) {
return
}
// AllParameterReferences returns json refs for all the discovered parameters
// AllParameterReferences returns JSON references for all the discovered parameters.
func (s *Spec) AllParameterReferences() (result []string) {
for _, v := range s.references.parameters {
result = append(result, v.String())
@@ -534,7 +534,7 @@ func (s *Spec) AllParameterReferences() (result []string) {
return
}
// AllResponseReferences returns json refs for all the discovered responses
// AllResponseReferences returns JSON references for all the discovered responses.
func (s *Spec) AllResponseReferences() (result []string) {
for _, v := range s.references.responses {
result = append(result, v.String())
@@ -543,7 +543,7 @@ func (s *Spec) AllResponseReferences() (result []string) {
return
}
// AllPathItemReferences returns the references for all the items
// AllPathItemReferences returns the references for all the items.
func (s *Spec) AllPathItemReferences() (result []string) {
for _, v := range s.references.pathItems {
result = append(result, v.String())
@@ -564,7 +564,7 @@ func (s *Spec) AllItemsReferences() (result []string) {
return
}
// AllReferences returns all the references found in the document, with possible duplicates
// AllReferences returns all the references found in the document, with possible duplicates.
func (s *Spec) AllReferences() (result []string) {
for _, v := range s.references.allRefs {
result = append(result, v.String())
@@ -573,7 +573,7 @@ func (s *Spec) AllReferences() (result []string) {
return
}
// AllRefs returns all the unique references found in the document
// AllRefs returns all the unique references found in the document.
func (s *Spec) AllRefs() (result []spec.Ref) {
set := make(map[string]struct{})
for _, v := range s.references.allRefs {
@@ -592,61 +592,61 @@ func (s *Spec) AllRefs() (result []spec.Ref) {
}
// ParameterPatterns returns all the patterns found in parameters
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) ParameterPatterns() map[string]string {
return cloneStringMap(s.patterns.parameters)
}
// HeaderPatterns returns all the patterns found in response headers
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) HeaderPatterns() map[string]string {
return cloneStringMap(s.patterns.headers)
}
// ItemsPatterns returns all the patterns found in simple array items
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) ItemsPatterns() map[string]string {
return cloneStringMap(s.patterns.items)
}
// SchemaPatterns returns all the patterns found in schemas
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) SchemaPatterns() map[string]string {
return cloneStringMap(s.patterns.schemas)
}
// AllPatterns returns all the patterns found in the spec
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) AllPatterns() map[string]string {
return cloneStringMap(s.patterns.allPatterns)
}
// ParameterEnums returns all the enums found in parameters
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) ParameterEnums() map[string][]any {
return cloneEnumMap(s.enums.parameters)
}
// HeaderEnums returns all the enums found in response headers
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) HeaderEnums() map[string][]any {
return cloneEnumMap(s.enums.headers)
}
// ItemsEnums returns all the enums found in simple array items
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) ItemsEnums() map[string][]any {
return cloneEnumMap(s.enums.items)
}
// SchemaEnums returns all the enums found in schemas
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) SchemaEnums() map[string][]any {
return cloneEnumMap(s.enums.schemas)
}
// AllEnums returns all the enums found in the spec
// the map is cloned to avoid accidental changes
// the map is cloned to avoid accidental changes.
func (s *Spec) AllEnums() map[string][]any {
return cloneEnumMap(s.enums.allEnums)
}
+1 -1
View File
@@ -9,4 +9,4 @@ import (
"github.com/go-openapi/analysis/internal/debug"
)
var debugLog = debug.GetLogger("analysis", os.Getenv("SWAGGER_DEBUG") != "")
var debugLog = debug.GetLogger("analysis", os.Getenv("SWAGGER_DEBUG") != "") //nolint:gochecknoglobals // it's okay to use a private global for logging
+27 -28
View File
@@ -1,32 +1,31 @@
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
/*
Package analysis provides methods to work with a Swagger specification document from
package go-openapi/spec.
## Analyzing a specification
An analysed specification object (type Spec) provides methods to work with swagger definition.
## Flattening or expanding a specification
Flattening a specification bundles all remote $ref in the main spec document.
Depending on flattening options, additional preprocessing may take place:
- full flattening: replacing all inline complex constructs by a named entry in #/definitions
- expand: replace all $ref's in the document by their expanded content
## Merging several specifications
Mixin several specifications merges all Swagger constructs, and warns about found conflicts.
## Fixing a specification
Unmarshalling a specification with golang json unmarshalling may lead to
some unwanted result on present but empty fields.
## Analyzing a Swagger schema
Swagger schemas are analyzed to determine their complexity and qualify their content.
*/
// Package analysis provides methods to work with a Swagger specification document from
// package go-openapi/spec.
//
// # Analyzing a specification
//
// An analysed specification object (type Spec) provides methods to work with swagger definition.
//
// # Flattening or expanding a specification
//
// Flattening a specification bundles all remote $ref in the main spec document.
// Depending on flattening options, additional preprocessing may take place:
//
// - full flattening: replacing all inline complex constructs by a named entry in #/definitions
// - expand: replace all $ref's in the document by their expanded content
//
// # Merging several specifications
//
// [Mixin] several specifications merges all Swagger constructs, and warns about found conflicts.
//
// # Fixing a specification
//
// Unmarshalling a specification with golang [json] unmarshalling may lead to
// some unwanted result on present but empty fields.
//
// # Analyzing a Swagger schema
//
// Swagger schemas are analyzed to determine their complexity and qualify their content.
package analysis
+47 -10
View File
@@ -21,7 +21,7 @@ import (
const definitionsPath = "#/definitions"
// newRef stores information about refs created during the flattening process
// newRef stores information about refs created during the flattening process.
type newRef struct {
key string
newName string
@@ -32,7 +32,7 @@ type newRef struct {
parents []string
}
// context stores intermediary results from flatten
// context stores intermediary results from flatten.
type context struct {
newRefs map[string]*newRef
warnings []string
@@ -52,13 +52,15 @@ func newContext() *context {
// There is a minimal and a full flattening mode.
//
// Minimally flattening a spec means:
//
// - Expanding parameters, responses, path items, parameter items and header items (references to schemas are left
// unscathed)
// - Importing external (http, file) references so they become internal to the document
// - Importing external ([http], file) references so they become internal to the document
// - Moving every JSON pointer to a $ref to a named definition (i.e. the reworked spec does not contain pointers
// like "$ref": "#/definitions/myObject/allOfs/1")
//
// A minimally flattened spec thus guarantees the following properties:
//
// - all $refs point to a local definition (i.e. '#/definitions/...')
// - definitions are unique
//
@@ -70,6 +72,7 @@ func newContext() *context {
// Minimal flattening is necessary and sufficient for codegen rendering using go-swagger.
//
// Fully flattening a spec means:
//
// - Moving every complex inline schema to be a definition with an auto-generated name in a depth-first fashion.
//
// By complex, we mean every JSON object with some properties.
@@ -80,6 +83,7 @@ func newContext() *context {
// have been created.
//
// Available flattening options:
//
// - Minimal: stops flattening after minimal $ref processing, leaving schema constructs untouched
// - Expand: expand all $ref's in the document (inoperant if Minimal set to true)
// - Verbose: croaks about name conflicts detected
@@ -87,8 +91,9 @@ func newContext() *context {
//
// NOTE: expansion removes all $ref save circular $ref, which remain in place
//
// TODO: additional options
// - ProgagateNameExtensions: ensure that created entries properly follow naming rules when their parent have set a
// Desirable future additions: additional options.
//
// - PropagateNameExtensions: ensure that created entries properly follow naming rules when their parent have set a
// x-go-name extension
// - LiftAllOfs:
// - limit the flattening of allOf members when simple objects
@@ -169,7 +174,7 @@ func expand(opts *FlattenOpts) error {
}
// normalizeRef strips the current file from any absolute file $ref. This works around issue go-openapi/spec#76:
// leading absolute file in $ref is stripped
// leading absolute file in $ref is stripped.
func normalizeRef(opts *FlattenOpts) error {
debugLog("normalizeRef")
@@ -491,14 +496,25 @@ func stripPointersAndOAIGen(opts *FlattenOpts) error {
// pointer and name resolution again.
func stripOAIGen(opts *FlattenOpts) (bool, error) {
debugLog("stripOAIGen")
// Ensure the spec analysis is fresh, as previous steps (namePointers, etc.) might have modified refs.
opts.Spec.reload()
replacedWithComplex := false
// figure out referers of OAIGen definitions (doing it before the ref start mutating)
for _, r := range opts.flattenContext.newRefs {
// Sort keys to ensure deterministic processing order
sortedKeys := make([]string, 0, len(opts.flattenContext.newRefs))
for k := range opts.flattenContext.newRefs {
sortedKeys = append(sortedKeys, k)
}
sort.Strings(sortedKeys)
for _, k := range sortedKeys {
r := opts.flattenContext.newRefs[k]
updateRefParents(opts.Spec.references.allRefs, r)
}
for k := range opts.flattenContext.newRefs {
for _, k := range sortedKeys {
r := opts.flattenContext.newRefs[k]
debugLog("newRefs[%s]: isOAIGen: %t, resolved: %t, name: %s, path:%s, #parents: %d, parents: %v, ref: %s",
k, r.isOAIGen, r.resolved, r.newName, r.path, len(r.parents), r.parents, r.schema.Ref.String())
@@ -521,7 +537,7 @@ func stripOAIGen(opts *FlattenOpts) (bool, error) {
return replacedWithComplex, nil
}
// updateRefParents updates all parents of an updated $ref
// updateRefParents updates all parents of an updated $ref.
func updateRefParents(allRefs map[string]spec.Ref, r *newRef) {
if !r.isOAIGen || r.resolved { // bail on already resolved entries (avoid looping)
return
@@ -580,6 +596,19 @@ func stripOAIGenForRef(opts *FlattenOpts, k string, r *newRef) (bool, error) {
replacedWithComplex = true
}
}
// update parents of the target ref (pr[0]) if it is also a newRef (OAIGen)
// This ensures that if the target is later deleted/merged, it knows about these new referers.
for _, nr := range opts.flattenContext.newRefs {
if nr.path == pr[0] && nr.isOAIGen && !nr.resolved {
for _, p := range pr[1:] {
if !slices.Contains(nr.parents, p) {
nr.parents = append(nr.parents, p)
}
}
break
}
}
}
// remove OAIGen definition
@@ -587,7 +616,15 @@ func stripOAIGenForRef(opts *FlattenOpts, k string, r *newRef) (bool, error) {
delete(opts.Swagger().Definitions, path.Base(r.path))
// propagate changes in ref index for keys which have this one as a parent
for kk, value := range opts.flattenContext.newRefs {
// Sort keys to ensure deterministic update order
propagateKeys := make([]string, 0, len(opts.flattenContext.newRefs))
for k := range opts.flattenContext.newRefs {
propagateKeys = append(propagateKeys, k)
}
sort.Strings(propagateKeys)
for _, kk := range propagateKeys {
value := opts.flattenContext.newRefs[kk]
if kk == k || !value.isOAIGen || value.resolved {
continue
}
+4 -4
View File
@@ -17,7 +17,7 @@ import (
"github.com/go-openapi/swag/mangling"
)
// InlineSchemaNamer finds a new name for an inlined type
// InlineSchemaNamer finds a new name for an inlined type.
type InlineSchemaNamer struct {
Spec *spec.Swagger
Operations map[string]operations.OpRef
@@ -25,7 +25,7 @@ type InlineSchemaNamer struct {
opts *FlattenOpts
}
// Name yields a new name for the inline schema
// Name yields a new name for the inline schema.
func (isn *InlineSchemaNamer) Name(key string, schema *spec.Schema, aschema *AnalyzedSchema) error {
debugLog("naming inlined schema at %s", key)
@@ -108,7 +108,7 @@ func (isn *InlineSchemaNamer) Name(key string, schema *spec.Schema, aschema *Ana
return nil
}
// uniqifyName yields a unique name for a definition
// uniqifyName yields a unique name for a definition.
func uniqifyName(definitions spec.Definitions, name string) (string, bool) {
isOAIGen := false
if name == "" {
@@ -244,7 +244,7 @@ func namesForDefinition(parts sortref.SplitKey) ([][]string, int) {
return [][]string{}, 0
}
// partAdder knows how to interpret a schema when it comes to build a name from parts
// partAdder knows how to interpret a schema when it comes to build a name from parts.
func partAdder(aschema *AnalyzedSchema) sortref.PartAdder {
return func(part string) []string {
segments := make([]string, 0, minSegments)
+3 -3
View File
@@ -35,7 +35,7 @@ type FlattenOpts struct {
_ struct{} // require keys
}
// ExpandOpts creates a spec.ExpandOptions to configure expanding a specification document.
// ExpandOpts creates a spec.[spec.ExpandOptions] to configure expanding a specification document.
func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *spec.ExpandOptions {
return &spec.ExpandOptions{
RelativeBase: f.BasePath,
@@ -44,13 +44,13 @@ func (f *FlattenOpts) ExpandOpts(skipSchemas bool) *spec.ExpandOptions {
}
}
// Swagger gets the swagger specification for this flatten operation
// Swagger gets the swagger specification for this flatten operation.
func (f *FlattenOpts) Swagger() *spec.Swagger {
return f.Spec.spec
}
// croak logs notifications and warnings about valid, but possibly unwanted constructs resulting
// from flattening a spec
// from flattening a spec.
func (f *FlattenOpts) croak() {
if !f.Verbose {
return
+6
View File
@@ -0,0 +1,6 @@
go 1.24.0
use (
.
./internal/testintegration
)
+29
View File
@@ -0,0 +1,29 @@
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30 h1:BHT1/DKsYDGkUgQ2jmMaozVcdk+sVfz0+1ZJq4zkWgw=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
+2 -4
View File
@@ -11,11 +11,9 @@ import (
"runtime"
)
var (
output = os.Stdout
)
var output = os.Stdout //nolint:gochecknoglobals // this is on purpose to be overridable during tests
// GetLogger provides a prefix debug logger
// GetLogger provides a prefix debug logger.
func GetLogger(prefix string, debug bool) func(string, ...any) {
if debug {
logger := log.New(output, prefix+":", log.LstdFlags)
@@ -17,8 +17,9 @@ import (
// NOTE: does not support JSONschema ID for $ref (we assume we are working with swagger specs here).
//
// NOTE(windows):
// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
// * "/ in paths may appear as escape sequences
//
// - refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
// - "/ in paths may appear as escape sequences.
func RebaseRef(baseRef string, ref string) string {
baseRef, _ = url.PathUnescape(baseRef)
ref, _ = url.PathUnescape(ref)
@@ -69,8 +70,9 @@ func RebaseRef(baseRef string, ref string) string {
// Path renders absolute path on remote file refs
//
// NOTE(windows):
// * refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
// * "/ in paths may appear as escape sequences
//
// - refs are assumed to have been normalized with drive letter lower cased (from go-openapi/spec)
// - "/ in paths may appear as escape sequences.
func Path(ref spec.Ref, basePath string) string {
uri, _ := url.PathUnescape(ref.String())
if ref.HasFragmentOnly || filepath.IsAbs(uri) {
@@ -14,12 +14,12 @@ import (
"github.com/go-openapi/swag/mangling"
)
// AllOpRefsByRef returns an index of sortable operations
// AllOpRefsByRef returns an index of sortable operations.
func AllOpRefsByRef(specDoc Provider, operationIDs []string) map[string]OpRef {
return OpRefsByRef(GatherOperations(specDoc, operationIDs))
}
// OpRefsByRef indexes a map of sortable operations
// OpRefsByRef indexes a map of sortable operations.
func OpRefsByRef(oprefs map[string]OpRef) map[string]OpRef {
result := make(map[string]OpRef, len(oprefs))
for _, v := range oprefs {
@@ -29,7 +29,7 @@ func OpRefsByRef(oprefs map[string]OpRef) map[string]OpRef {
return result
}
// OpRef is an indexable, sortable operation
// OpRef is an indexable, sortable operation.
type OpRef struct {
Method string
Path string
@@ -39,19 +39,19 @@ type OpRef struct {
Ref spec.Ref
}
// OpRefs is a sortable collection of operations
// OpRefs is a sortable collection of operations.
type OpRefs []OpRef
func (o OpRefs) Len() int { return len(o) }
func (o OpRefs) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
func (o OpRefs) Less(i, j int) bool { return o[i].Key < o[j].Key }
// Provider knows how to collect operations from a spec
// Provider knows how to collect operations from a spec.
type Provider interface {
Operations() map[string]map[string]*spec.Operation
}
// GatherOperations builds a map of sorted operations from a spec
// GatherOperations builds a map of sorted operations from a spec.
func GatherOperations(specDoc Provider, operationIDs []string) map[string]OpRef {
var oprefs OpRefs
mangler := mangling.NewNameMangler()
+1 -1
View File
@@ -58,7 +58,7 @@ func ErrCyclicChain(key string) error {
}
func ErrInvalidPointerType(key string, value any, err error) error {
return fmt.Errorf("invalid type for resolved JSON pointer %s. Expected a schema a, got: %T (%v): %w",
return fmt.Errorf("invalid type for resolved JSON pointer %s. Expected a schema a, got: %T (%w): %w",
key, value, err, ErrReplace,
)
}
+29 -14
View File
@@ -22,9 +22,10 @@ const (
allocMediumMap = 64
)
//nolint:gochecknoglobals // it's okay to use a private global for logging
var debugLog = debug.GetLogger("analysis/flatten/replace", os.Getenv("SWAGGER_DEBUG") != "")
// RewriteSchemaToRef replaces a schema with a Ref
// RewriteSchemaToRef replaces a schema with a Ref.
func RewriteSchemaToRef(sp *spec.Swagger, key string, ref spec.Ref) error {
debugLog("rewriting schema to ref for %s with %s", key, ref.String())
_, value, err := getPointerFromKey(sp, key)
@@ -142,7 +143,7 @@ func rewriteParentRef(sp *spec.Swagger, key string, ref spec.Ref) error {
return nil
}
// getPointerFromKey retrieves the content of the JSON pointer "key"
// getPointerFromKey retrieves the content of the JSON pointer "key".
func getPointerFromKey(sp any, key string) (string, any, error) {
switch sp.(type) {
case *spec.Schema:
@@ -154,7 +155,10 @@ func getPointerFromKey(sp any, key string) (string, any, error) {
return "", sp, nil
}
// unescape chars in key, e.g. "{}" from path params
pth, _ := url.PathUnescape(key[1:])
pth, err := url.PathUnescape(key[1:])
if err != nil {
return "", nil, errors.Join(err, ErrReplace)
}
ptr, err := jsonpointer.New(pth)
if err != nil {
return "", nil, errors.Join(err, ErrReplace)
@@ -170,7 +174,7 @@ func getPointerFromKey(sp any, key string) (string, any, error) {
return pth, value, nil
}
// getParentFromKey retrieves the container of the JSON pointer "key"
// getParentFromKey retrieves the container of the JSON pointer "key".
func getParentFromKey(sp any, key string) (string, string, any, error) {
switch sp.(type) {
case *spec.Schema:
@@ -196,7 +200,7 @@ func getParentFromKey(sp any, key string) (string, string, any, error) {
return parent, entry, pvalue, nil
}
// UpdateRef replaces a ref by another one
// UpdateRef replaces a ref by another one.
func UpdateRef(sp any, key string, ref spec.Ref) error {
switch sp.(type) {
case *spec.Schema:
@@ -265,7 +269,7 @@ func UpdateRef(sp any, key string, ref spec.Ref) error {
return nil
}
// UpdateRefWithSchema replaces a ref with a schema (i.e. re-inline schema)
// UpdateRefWithSchema replaces a ref with a schema (i.e. re-inline schema).
func UpdateRefWithSchema(sp *spec.Swagger, key string, sch *spec.Schema) error {
debugLog("updating ref for %s with schema", key)
pth, value, err := getPointerFromKey(sp, key)
@@ -324,7 +328,7 @@ func UpdateRefWithSchema(sp *spec.Swagger, key string, sch *spec.Schema) error {
return nil
}
// DeepestRefResult holds the results from DeepestRef analysis
// DeepestRefResult holds the results from [DeepestRef] analysis.
type DeepestRefResult struct {
Ref spec.Ref
Schema *spec.Schema
@@ -332,10 +336,13 @@ type DeepestRefResult struct {
}
// DeepestRef finds the first definition ref, from a cascade of nested refs which are not definitions.
//
// - if no definition is found, returns the deepest ref.
// - pointers to external files are expanded
//
// NOTE: all external $ref's are assumed to be already expanded at this stage.
//
//nolint:gocognit,gocyclo,cyclop // definitely needs a refactoring, in a follow-up PR
func DeepestRef(sp *spec.Swagger, opts *spec.ExpandOptions, ref spec.Ref) (*DeepestRefResult, error) {
if !ref.HasFragmentOnly {
// we found an external $ref, which is odd at this stage:
@@ -392,11 +399,13 @@ DOWNREF:
case spec.Response:
// a pointer points to a schema initially marshalled in responses section...
// Attempt to convert this to a schema. If this fails, the spec is invalid
asJSON, _ := refable.MarshalJSON()
asJSON, err := refable.MarshalJSON()
if err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
var asSchema spec.Schema
err := asSchema.UnmarshalJSON(asJSON)
if err != nil {
if err = asSchema.UnmarshalJSON(asJSON); err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
warnings = append(warnings, fmt.Sprintf("found $ref %q (response) interpreted as schema", currentRef.String()))
@@ -409,9 +418,12 @@ DOWNREF:
case spec.Parameter:
// a pointer points to a schema initially marshalled in parameters section...
// Attempt to convert this to a schema. If this fails, the spec is invalid
asJSON, _ := refable.MarshalJSON()
asJSON, err := refable.MarshalJSON()
if err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
var asSchema spec.Schema
if err := asSchema.UnmarshalJSON(asJSON); err != nil {
if err = asSchema.UnmarshalJSON(asJSON); err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
@@ -428,9 +440,12 @@ DOWNREF:
break DOWNREF
}
asJSON, _ := json.Marshal(refable)
asJSON, err := json.Marshal(refable)
if err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
var asSchema spec.Schema
if err := asSchema.UnmarshalJSON(asJSON); err != nil {
if err = asSchema.UnmarshalJSON(asJSON); err != nil {
return nil, ErrInvalidPointerType(currentRef.String(), value, err)
}
warnings = append(warnings, fmt.Sprintf("found $ref %q (%T) interpreted as schema", currentRef.String(), refable))
@@ -12,7 +12,7 @@ import (
const allocLargeMap = 150
// Save registers a schema as an entry in spec #/definitions
// Save registers a schema as an entry in spec #/definitions.
func Save(sp *spec.Swagger, name string, schema *spec.Schema) {
if schema == nil {
return
@@ -25,7 +25,7 @@ func Save(sp *spec.Swagger, name string, schema *spec.Schema) {
sp.Definitions[name] = *schema
}
// Clone deep-clones a schema
// Clone deep-clones a schema.
func Clone(schema *spec.Schema) *spec.Schema {
var sch spec.Schema
_ = jsonutils.FromDynamicJSON(schema, &sch)
+20 -24
View File
@@ -20,12 +20,8 @@ const (
definitions = "definitions"
)
//nolint:gochecknoglobals // it's okay to store small indexes like this as private globals
var (
ignoredKeys map[string]struct{}
validMethods map[string]struct{}
)
func init() {
ignoredKeys = map[string]struct{}{
"schema": {},
"properties": {},
@@ -43,15 +39,15 @@ func init() {
"PUT": {},
"DELETE": {},
}
}
)
// Key represent a key item constructed from /-separated segments
// Key represent a key item constructed from /-separated segments.
type Key struct {
Segments int
Key string
}
// Keys is a sortable collable collection of Keys
// Keys is a sortable collable collection of Keys.
type Keys []Key
func (k Keys) Len() int { return len(k) }
@@ -60,7 +56,7 @@ func (k Keys) Less(i, j int) bool {
return k[i].Segments > k[j].Segments || (k[i].Segments == k[j].Segments && k[i].Key < k[j].Key)
}
// KeyParts construct a SplitKey with all its /-separated segments decomposed. It is sortable.
// KeyParts construct a [SplitKey] with all its /-separated segments decomposed. It is sortable.
func KeyParts(key string) SplitKey {
var res []string
for part := range strings.SplitSeq(key[1:], "/") {
@@ -75,12 +71,12 @@ func KeyParts(key string) SplitKey {
// SplitKey holds of the parts of a /-separated key, so that their location may be determined.
type SplitKey []string
// IsDefinition is true when the split key is in the #/definitions section of a spec
// IsDefinition is true when the split key is in the #/definitions section of a spec.
func (s SplitKey) IsDefinition() bool {
return len(s) > 1 && s[0] == definitions
}
// DefinitionName yields the name of the definition
// DefinitionName yields the name of the definition.
func (s SplitKey) DefinitionName() string {
if !s.IsDefinition() {
return ""
@@ -89,10 +85,10 @@ func (s SplitKey) DefinitionName() string {
return s[1]
}
// PartAdder know how to construct the components of a new name
// PartAdder know how to construct the components of a new name.
type PartAdder func(string) []string
// BuildName builds a name from segments
// BuildName builds a name from segments.
func (s SplitKey) BuildName(segments []string, startIndex int, adder PartAdder) string {
for i, part := range s[startIndex:] {
if _, ignored := ignoredKeys[part]; !ignored || s.isKeyName(startIndex+i) {
@@ -103,42 +99,42 @@ func (s SplitKey) BuildName(segments []string, startIndex int, adder PartAdder)
return strings.Join(segments, " ")
}
// IsOperation is true when the split key is in the operations section
// IsOperation is true when the split key is in the operations section.
func (s SplitKey) IsOperation() bool {
return len(s) > 1 && s[0] == paths
}
// IsSharedOperationParam is true when the split key is in the parameters section of a path
// IsSharedOperationParam is true when the split key is in the parameters section of a path.
func (s SplitKey) IsSharedOperationParam() bool {
return len(s) > 2 && s[0] == paths && s[2] == parameters
}
// IsSharedParam is true when the split key is in the #/parameters section of a spec
// IsSharedParam is true when the split key is in the #/parameters section of a spec.
func (s SplitKey) IsSharedParam() bool {
return len(s) > 1 && s[0] == parameters
}
// IsOperationParam is true when the split key is in the parameters section of an operation
// IsOperationParam is true when the split key is in the parameters section of an operation.
func (s SplitKey) IsOperationParam() bool {
return len(s) > 3 && s[0] == paths && s[3] == parameters
}
// IsOperationResponse is true when the split key is in the responses section of an operation
// IsOperationResponse is true when the split key is in the responses section of an operation.
func (s SplitKey) IsOperationResponse() bool {
return len(s) > 3 && s[0] == paths && s[3] == responses
}
// IsSharedResponse is true when the split key is in the #/responses section of a spec
// IsSharedResponse is true when the split key is in the #/responses section of a spec.
func (s SplitKey) IsSharedResponse() bool {
return len(s) > 1 && s[0] == responses
}
// IsDefaultResponse is true when the split key is the default response for an operation
// IsDefaultResponse is true when the split key is the default response for an operation.
func (s SplitKey) IsDefaultResponse() bool {
return len(s) > 4 && s[0] == paths && s[3] == responses && s[4] == "default"
}
// IsStatusCodeResponse is true when the split key is an operation response with a status code
// IsStatusCodeResponse is true when the split key is an operation response with a status code.
func (s SplitKey) IsStatusCodeResponse() bool {
isInt := func() bool {
_, err := strconv.Atoi(s[4])
@@ -149,7 +145,7 @@ func (s SplitKey) IsStatusCodeResponse() bool {
return len(s) > 4 && s[0] == paths && s[3] == responses && isInt()
}
// ResponseName yields either the status code or "Default" for a response
// ResponseName yields either the status code or "Default" for a response.
func (s SplitKey) ResponseName() string {
if s.IsStatusCodeResponse() {
code, _ := strconv.Atoi(s[4])
@@ -164,7 +160,7 @@ func (s SplitKey) ResponseName() string {
return ""
}
// PathItemRef constructs a $ref object from a split key of the form /{path}/{method}
// PathItemRef constructs a $ref object from a split key of the form /{path}/{method}.
func (s SplitKey) PathItemRef() spec.Ref {
const minValidPathItems = 3
if len(s) < minValidPathItems {
@@ -179,7 +175,7 @@ func (s SplitKey) PathItemRef() spec.Ref {
return spec.MustCreateRef("#" + path.Join("/", paths, jsonpointer.Escape(pth), strings.ToUpper(method)))
}
// PathRef constructs a $ref object from a split key of the form /paths/{reference}
// PathRef constructs a $ref object from a split key of the form /paths/{reference}.
func (s SplitKey) PathRef() spec.Ref {
if !s.IsOperation() {
return spec.Ref{}
+13 -9
View File
@@ -4,7 +4,9 @@
package sortref
import (
"iter"
"reflect"
"slices"
"sort"
"strings"
@@ -12,10 +14,6 @@ import (
"github.com/go-openapi/spec"
)
var depthGroupOrder = []string{
"sharedParam", "sharedResponse", "sharedOpParam", "opParam", "codeResponse", "defaultResponse", "definition",
}
type mapIterator struct {
len int
mapIter *reflect.MapIter
@@ -42,7 +40,7 @@ func mustMapIterator(anyMap any) *mapIterator {
// DepthFirst sorts a map of anything. It groups keys by category
// (shared params, op param, statuscode response, default response, definitions)
// sort groups internally by number of parts in the key and lexical names
// flatten groups into a single list of keys
// flatten groups into a single list of keys.
func DepthFirst(in any) []string {
iterator := mustMapIterator(in)
sorted := make([]string, 0, iterator.Len())
@@ -77,7 +75,7 @@ func DepthFirst(in any) []string {
grouped[pk] = append(grouped[pk], Key{Segments: len(split), Key: k})
}
for _, pk := range depthGroupOrder {
for pk := range depthGroupOrder() {
res := grouped[pk]
sort.Sort(res)
@@ -89,6 +87,12 @@ func DepthFirst(in any) []string {
return sorted
}
func depthGroupOrder() iter.Seq[string] {
return slices.Values([]string{
"sharedParam", "sharedResponse", "sharedOpParam", "opParam", "codeResponse", "defaultResponse", "definition",
})
}
// topMostRefs is able to sort refs by hierarchical then lexicographic order,
// yielding refs ordered breadth-first.
type topmostRefs []string
@@ -104,7 +108,7 @@ func (k topmostRefs) Less(i, j int) bool {
return li < lj
}
// TopmostFirst sorts references by depth
// TopmostFirst sorts references by depth.
func TopmostFirst(refs []string) []string {
res := topmostRefs(refs)
sort.Sort(res)
@@ -112,13 +116,13 @@ func TopmostFirst(refs []string) []string {
return res
}
// RefRevIdx is a reverse index for references
// RefRevIdx is a reverse index for references.
type RefRevIdx struct {
Ref spec.Ref
Keys []string
}
// ReverseIndex builds a reverse index for references in schemas
// ReverseIndex builds a reverse index for references in schemas.
func ReverseIndex(schemas map[string]spec.Ref, basePath string) map[string]RefRevIdx {
collected := make(map[string]RefRevIdx)
for key, schRef := range schemas {
+3 -2
View File
@@ -18,12 +18,13 @@ import (
// needed.
//
// The following parts of primary are subject to merge, filling empty details
//
// - Info
// - BasePath
// - Host
// - ExternalDocs
//
// Consider calling FixEmptyResponseDescriptions() on the modified primary
// Consider calling [FixEmptyResponseDescriptions]() on the modified primary
// if you read them from storage and they are valid to start with.
//
// Entries in "paths", "definitions", "parameters" and "responses" are
@@ -39,7 +40,7 @@ import (
// etc). Ensure they are canonical if your downstream tools do
// key normalization of any form.
//
// Merging schemes (http, https), and consumers/producers do not account for
// Merging schemes ([http], https), and consumers/producers do not account for
// collisions.
func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string {
skipped := make([]string, 0, len(mixins))
+3 -3
View File
@@ -8,7 +8,7 @@ import (
"github.com/go-openapi/strfmt"
)
// SchemaOpts configures the schema analyzer
// SchemaOpts configures the schema analyzer.
type SchemaOpts struct {
Schema *spec.Schema
Root any
@@ -52,7 +52,7 @@ func Schema(opts SchemaOpts) (*AnalyzedSchema, error) {
return a, nil
}
// AnalyzedSchema indicates what the schema represents
// AnalyzedSchema indicates what the schema represents.
type AnalyzedSchema struct {
schema *spec.Schema
root any
@@ -78,7 +78,7 @@ type AnalyzedSchema struct {
IsEnum bool
}
// Inherits copies value fields from other onto this schema
// Inherits copies value fields from other onto this schema.
func (a *AnalyzedSchema) inherits(other *AnalyzedSchema) {
if other == nil {
return
-181
View File
@@ -1,181 +0,0 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[changelog]
header = """
"""
footer = """
-----
**[{{ remote.github.repo }}]({{ self::remote_url() }}) license terms**
[![License][license-badge]][license-url]
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: {{ self::remote_url() }}/?tab=Apache-2.0-1-ov-file#readme
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
body = """
{%- if version %}
## [{{ version | trim_start_matches(pat="v") }}]({{ self::remote_url() }}/tree/{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else %}
## [unreleased]
{%- endif %}
{%- if message %}
{%- raw %}\n{% endraw %}
{{ message }}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if version %}
{%- if previous.version %}
**Full Changelog**: <{{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}>
{%- endif %}
{%- else %}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if statistics %}{% if statistics.commit_count %}
{%- raw %}\n{% endraw %}
{{ statistics.commit_count }} commits in this release.
{%- raw %}\n{% endraw %}
{%- endif %}{% endif %}
-----
{%- for group, commits in commits | group_by(attribute="group") %}
{%- raw %}\n{% endraw %}
### {{ group | upper_first }}
{%- raw %}\n{% endraw %}
{%- for commit in commits %}
{%- if commit.remote.pr_title %}
{%- set commit_message = commit.remote.pr_title %}
{%- else %}
{%- set commit_message = commit.message %}
{%- endif %}
* {{ commit_message | split(pat="\n") | first | trim }}
{%- if commit.remote.username %}
{%- raw %} {% endraw %}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})
{%- endif %}
{%- if commit.remote.pr_number %}
{%- raw %} {% endraw %}in [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})
{%- endif %}
{%- raw %} {% endraw %}[...]({{ self::remote_url() }}/commit/{{ commit.id }})
{%- endfor %}
{%- endfor %}
{%- if github %}
{%- raw %}\n{% endraw -%}
{%- set all_contributors = github.contributors | length %}
{%- if github.contributors | filter(attribute="username", value="dependabot[bot]") | length < all_contributors %}
-----
### People who contributed to this release
{% endif %}
{%- for contributor in github.contributors | filter(attribute="username") | sort(attribute="username") %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }})
{%- endif %}
{%- endfor %}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
-----
{%- raw %}\n{% endraw %}
### New Contributors
{%- endif %}
{%- for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* @{{ contributor.username }} made their first contribution
{%- if contributor.pr_number %}
in [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- raw %}\n{% endraw %}
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
# Render body even when there are no releases to process.
render_always = true
# An array of regex based postprocessors to modify the changelog.
postprocessors = [
# Replace the placeholder <REPO> with a URL.
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
]
# output file path
# output = "test.md"
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
conventional_commits = false
# Exclude commits that do not match the conventional commits specification.
filter_unconventional = false
# Require all commits to be conventional.
# Takes precedence over filter_unconventional.
require_conventional = false
# Split commits on newlines, treating each line as an individual commit.
split_commits = false
# An array of regex based parsers to modify commit messages prior to further processing.
commit_preprocessors = [
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit message using https://github.com/crate-ci/typos.
# If the spelling is incorrect, it will be fixed automatically.
#{ pattern = '.*', replace_command = 'typos --write-changes -' }
]
# Prevent commits that are breaking from being excluded by commit parsers.
protect_breaking_commits = false
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^[Cc]hore\\([Rr]elease\\): prepare for", skip = true },
{ message = "(^[Mm]erge)|([Mm]erge conflict)", skip = true },
{ field = "author.name", pattern = "dependabot*", group = "<!-- 0A -->Updates" },
{ message = "([Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ body = "(.*[Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ message = "([Cc]hore\\(lint\\))|(style)|(lint)|(codeql)|(golangci)", group = "<!-- 05 -->Code quality" },
{ message = "(^[Dd]oc)|((?i)readme)|(badge)|(typo)|(documentation)", group = "<!-- 03 -->Documentation" },
{ message = "(^[Ff]eat)|(^[Ee]nhancement)", group = "<!-- 00 -->Implemented enhancements" },
{ message = "(^ci)|(\\(ci\\))|(fixup\\s+ci)|(fix\\s+ci)|(license)|(example)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^test", group = "<!-- 06 -->Testing" },
{ message = "(^fix)|(panic)", group = "<!-- 01 -->Fixed bugs" },
{ message = "(^refact)|(rework)", group = "<!-- 02 -->Refactor" },
{ message = "(^[Pp]erf)|(performance)", group = "<!-- 04 -->Performance" },
{ message = "(^[Cc]hore)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^[Rr]evert", group = "<!-- 09 -->Reverted changes" },
{ message = "(upgrade.*?go)|(go\\s+version)", group = "<!-- 0A -->Updates" },
{ message = ".*", group = "<!-- 0B -->Other" },
]
# Exclude commits that are not matched by any commit parser.
filter_commits = false
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
link_parsers = []
# Include only the tags that belong to the current branch.
use_branch_tags = false
# Order releases topologically instead of chronologically.
topo_order = false
# Order releases topologically instead of chronologically.
topo_order_commits = true
# Order of commits in each group/release within the changelog.
# Allowed values: newest, oldest
sort_commits = "newest"
# Process submodules commits
recurse_submodules = false
#[remote.github]
#owner = "go-openapi"
+5 -1
View File
@@ -1,3 +1,7 @@
secrets.yml
*.out
*.cov
.idea
.env
.mcp.json
.claude/
settings.local.json
+5
View File
@@ -12,6 +12,7 @@ linters:
- paralleltest
- recvcheck
- testpackage
- thelper
- tparallel
- varnamelen
- whitespace
@@ -40,6 +41,10 @@ linters:
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- revive
text: "avoid package names that conflict with Go standard library package names"
paths:
- third_party$
- builtin$
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+14 -13
View File
@@ -4,21 +4,22 @@
| Total Contributors | Total Contributions |
| --- | --- |
| 12 | 105 |
| 13 | 110 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @casualjim | 58 | https://github.com/go-openapi/errors/commits?author=casualjim |
| @fredbi | 32 | https://github.com/go-openapi/errors/commits?author=fredbi |
| @youyuanwu | 5 | https://github.com/go-openapi/errors/commits?author=youyuanwu |
| @alexandear | 2 | https://github.com/go-openapi/errors/commits?author=alexandear |
| @fiorix | 1 | https://github.com/go-openapi/errors/commits?author=fiorix |
| @ligustah | 1 | https://github.com/go-openapi/errors/commits?author=ligustah |
| @artemseleznev | 1 | https://github.com/go-openapi/errors/commits?author=artemseleznev |
| @gautierdelorme | 1 | https://github.com/go-openapi/errors/commits?author=gautierdelorme |
| @guillemj | 1 | https://github.com/go-openapi/errors/commits?author=guillemj |
| @maxatome | 1 | https://github.com/go-openapi/errors/commits?author=maxatome |
| @Simon-Li | 1 | https://github.com/go-openapi/errors/commits?author=Simon-Li |
| @ujjwalsh | 1 | https://github.com/go-openapi/errors/commits?author=ujjwalsh |
| @casualjim | 58 | <https://github.com/go-openapi/errors/commits?author=casualjim> |
| @fredbi | 36 | <https://github.com/go-openapi/errors/commits?author=fredbi> |
| @youyuanwu | 5 | <https://github.com/go-openapi/errors/commits?author=youyuanwu> |
| @alexandear | 2 | <https://github.com/go-openapi/errors/commits?author=alexandear> |
| @fiorix | 1 | <https://github.com/go-openapi/errors/commits?author=fiorix> |
| @ligustah | 1 | <https://github.com/go-openapi/errors/commits?author=ligustah> |
| @artemseleznev | 1 | <https://github.com/go-openapi/errors/commits?author=artemseleznev> |
| @gautierdelorme | 1 | <https://github.com/go-openapi/errors/commits?author=gautierdelorme> |
| @guillemj | 1 | <https://github.com/go-openapi/errors/commits?author=guillemj> |
| @maxatome | 1 | <https://github.com/go-openapi/errors/commits?author=maxatome> |
| @Simon-Li | 1 | <https://github.com/go-openapi/errors/commits?author=Simon-Li> |
| @aokumasan | 1 | <https://github.com/go-openapi/errors/commits?author=aokumasan> |
| @ujjwalsh | 1 | <https://github.com/go-openapi/errors/commits?author=ujjwalsh> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_
+4 -9
View File
@@ -51,7 +51,9 @@ errNotImplemented := NotImplemented("method: %s", url)
See <https://github.com/go-openapi/errors/releases>
<!--
## References
-->
## Licensing
@@ -59,12 +61,9 @@ See <https://github.com/go-openapi/errors/releases>
This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE).
<!--
See the license [NOTICE](./NOTICE), which recalls the licensing terms of all the pieces of software
on top of which it has been built.
-->
<!--
## Limitations
-->
## Other documentation
@@ -95,23 +94,19 @@ Maintainers can cut a new release by either:
<!-- Badges: release & docker images -->
[release-badge]: https://badge.fury.io/gh/go-openapi%2Ferrors.svg
[release-url]: https://badge.fury.io/gh/go-openapi%2Ferrors
[gomod-badge]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Ferrors.svg
[gomod-url]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Ferrors
<!-- Badges: code quality -->
[gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/errors
[gocard-url]: https://goreportcard.com/report/github.com/go-openapi/errors
[codefactor-badge]: https://img.shields.io/codefactor/grade/github/go-openapi/errors
[codefactor-url]: https://www.codefactor.io/repository/github/go-openapi/errors
<!-- Badges: documentation & support -->
[doc-badge]: https://img.shields.io/badge/doc-site-blue?link=https%3A%2F%2Fgoswagger.io%2Fgo-openapi%2F
[doc-url]: https://goswagger.io/go-openapi
[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/errors
[godoc-url]: http://pkg.go.dev/github.com/go-openapi/errors
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/DrafRmZx
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
+23 -5
View File
@@ -6,14 +6,32 @@ This policy outlines the commitment and practices of the go-openapi maintainers
| Version | Supported |
| ------- | ------------------ |
| 0.22.x | :white_check_mark: |
| 0.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
please report it privately to the maintainers.
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to
[Privately report a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
TL;DR: on Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
+1 -1
View File
@@ -146,7 +146,7 @@ func MethodNotAllowed(requested string, allow []string) Error {
}
}
// ServeError implements the http error handler interface.
// ServeError implements the [http] error handler interface.
func ServeError(rw http.ResponseWriter, r *http.Request, err error) {
rw.Header().Set("Content-Type", "application/json")
+9 -11
View File
@@ -1,15 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
/*
Package errors provides an Error interface and several concrete types
implementing this interface to manage API errors and JSON-schema validation
errors.
A middleware handler ServeError() is provided to serve the errors types
it defines.
It is used throughout the various go-openapi toolkit libraries
(https://github.com/go-openapi).
*/
// Package errors provides an Error interface and several concrete types
// implementing this interface to manage API errors and JSON-schema validation
// errors.
//
// A middleware handler [ServeError]() is provided to serve the errors types
// it defines.
//
// It is used throughout the various go-openapi toolkit libraries.
// (https://github.com/go-openapi).
package errors
+2
View File
@@ -2,3 +2,5 @@
*.cov
.idea
.env
.mcp.json
.claude/
+1
View File
@@ -12,6 +12,7 @@ linters:
- paralleltest
- recvcheck
- testpackage
- thelper
- tparallel
- varnamelen
- whitespace
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+13 -13
View File
@@ -4,21 +4,21 @@
| Total Contributors | Total Contributions |
| --- | --- |
| 12 | 95 |
| 12 | 101 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @fredbi | 48 | https://github.com/go-openapi/jsonpointer/commits?author=fredbi |
| @casualjim | 33 | https://github.com/go-openapi/jsonpointer/commits?author=casualjim |
| @magodo | 3 | https://github.com/go-openapi/jsonpointer/commits?author=magodo |
| @youyuanwu | 3 | https://github.com/go-openapi/jsonpointer/commits?author=youyuanwu |
| @gaiaz-iusipov | 1 | https://github.com/go-openapi/jsonpointer/commits?author=gaiaz-iusipov |
| @gbjk | 1 | https://github.com/go-openapi/jsonpointer/commits?author=gbjk |
| @gordallott | 1 | https://github.com/go-openapi/jsonpointer/commits?author=gordallott |
| @ianlancetaylor | 1 | https://github.com/go-openapi/jsonpointer/commits?author=ianlancetaylor |
| @mfleader | 1 | https://github.com/go-openapi/jsonpointer/commits?author=mfleader |
| @Neo2308 | 1 | https://github.com/go-openapi/jsonpointer/commits?author=Neo2308 |
| @olivierlemasle | 1 | https://github.com/go-openapi/jsonpointer/commits?author=olivierlemasle |
| @testwill | 1 | https://github.com/go-openapi/jsonpointer/commits?author=testwill |
| @fredbi | 54 | <https://github.com/go-openapi/jsonpointer/commits?author=fredbi> |
| @casualjim | 33 | <https://github.com/go-openapi/jsonpointer/commits?author=casualjim> |
| @magodo | 3 | <https://github.com/go-openapi/jsonpointer/commits?author=magodo> |
| @youyuanwu | 3 | <https://github.com/go-openapi/jsonpointer/commits?author=youyuanwu> |
| @gaiaz-iusipov | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=gaiaz-iusipov> |
| @gbjk | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=gbjk> |
| @gordallott | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=gordallott> |
| @ianlancetaylor | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=ianlancetaylor> |
| @mfleader | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=mfleader> |
| @Neo2308 | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=Neo2308> |
| @olivierlemasle | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=olivierlemasle> |
| @testwill | 1 | <https://github.com/go-openapi/jsonpointer/commits?author=testwill> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_
+14 -5
View File
@@ -8,12 +8,22 @@
[![Release][release-badge]][release-url] [![Go Report Card][gocard-badge]][gocard-url] [![CodeFactor Grade][codefactor-badge]][codefactor-url] [![License][license-badge]][license-url]
<!-- Badges: documentation & support -->
<!-- Badges: others & stats -->
[![GoDoc][godoc-badge]][godoc-url] [![Slack Channel][slack-logo]![slack-badge]][slack-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
[![GoDoc][godoc-badge]][godoc-url] [![Discord Channel][discord-badge]][discord-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
---
An implementation of JSON Pointer for golang, which supports go `struct`.
## Announcements
* **2025-12-19** : new community chat on discord
* a new discord community channel is available to be notified of changes and support users
* our venerable Slack channel remains open, and will be eventually discontinued on **2026-03-31**
You may join the discord community by clicking the invite link on the discord badge (also above). [![Discord Channel][discord-badge]][discord-url]
Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url]
## Status
API is stable.
@@ -124,21 +134,20 @@ Maintainers can cut a new release by either:
<!-- Badges: release & docker images -->
[release-badge]: https://badge.fury.io/gh/go-openapi%2Fjsonpointer.svg
[release-url]: https://badge.fury.io/gh/go-openapi%2Fjsonpointer
[gomod-badge]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fjsonpointer.svg
[gomod-url]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fjsonpointer
<!-- Badges: code quality -->
[gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/jsonpointer
[gocard-url]: https://goreportcard.com/report/github.com/go-openapi/jsonpointer
[codefactor-badge]: https://img.shields.io/codefactor/grade/github/go-openapi/jsonpointer
[codefactor-url]: https://www.codefactor.io/repository/github/go-openapi/jsonpointer
<!-- Badges: documentation & support -->
[doc-badge]: https://img.shields.io/badge/doc-site-blue?link=https%3A%2F%2Fgoswagger.io%2Fgo-openapi%2F
[doc-url]: https://goswagger.io/go-openapi
[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/jsonpointer
[godoc-url]: http://pkg.go.dev/github.com/go-openapi/jsonpointer
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: https://github.com/go-openapi/jsonpointer/?tab=Apache-2.0-1-ov-file#readme
+23 -5
View File
@@ -6,14 +6,32 @@ This policy outlines the commitment and practices of the go-openapi maintainers
| Version | Supported |
| ------- | ------------------ |
| 0.22.x | :white_check_mark: |
| O.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
please report it privately to the maintainers.
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to
[Privately report a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
TL;DR: on Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
-181
View File
@@ -1,181 +0,0 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[changelog]
header = """
"""
footer = """
-----
**[{{ remote.github.repo }}]({{ self::remote_url() }}) license terms**
[![License][license-badge]][license-url]
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: {{ self::remote_url() }}/?tab=Apache-2.0-1-ov-file#readme
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
body = """
{%- if version %}
## [{{ version | trim_start_matches(pat="v") }}]({{ self::remote_url() }}/tree/{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else %}
## [unreleased]
{%- endif %}
{%- if message %}
{%- raw %}\n{% endraw %}
{{ message }}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if version %}
{%- if previous.version %}
**Full Changelog**: <{{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}>
{%- endif %}
{%- else %}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if statistics %}{% if statistics.commit_count %}
{%- raw %}\n{% endraw %}
{{ statistics.commit_count }} commits in this release.
{%- raw %}\n{% endraw %}
{%- endif %}{% endif %}
-----
{%- for group, commits in commits | group_by(attribute="group") %}
{%- raw %}\n{% endraw %}
### {{ group | upper_first }}
{%- raw %}\n{% endraw %}
{%- for commit in commits %}
{%- if commit.remote.pr_title %}
{%- set commit_message = commit.remote.pr_title %}
{%- else %}
{%- set commit_message = commit.message %}
{%- endif %}
* {{ commit_message | split(pat="\n") | first | trim }}
{%- if commit.remote.username %}
{%- raw %} {% endraw %}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})
{%- endif %}
{%- if commit.remote.pr_number %}
{%- raw %} {% endraw %}in [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})
{%- endif %}
{%- raw %} {% endraw %}[...]({{ self::remote_url() }}/commit/{{ commit.id }})
{%- endfor %}
{%- endfor %}
{%- if github %}
{%- raw %}\n{% endraw -%}
{%- set all_contributors = github.contributors | length %}
{%- if github.contributors | filter(attribute="username", value="dependabot[bot]") | length < all_contributors %}
-----
### People who contributed to this release
{% endif %}
{%- for contributor in github.contributors | filter(attribute="username") | sort(attribute="username") %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }})
{%- endif %}
{%- endfor %}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
-----
{%- raw %}\n{% endraw %}
### New Contributors
{%- endif %}
{%- for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* @{{ contributor.username }} made their first contribution
{%- if contributor.pr_number %}
in [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- raw %}\n{% endraw %}
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
# Render body even when there are no releases to process.
render_always = true
# An array of regex based postprocessors to modify the changelog.
postprocessors = [
# Replace the placeholder <REPO> with a URL.
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
]
# output file path
# output = "test.md"
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
conventional_commits = false
# Exclude commits that do not match the conventional commits specification.
filter_unconventional = false
# Require all commits to be conventional.
# Takes precedence over filter_unconventional.
require_conventional = false
# Split commits on newlines, treating each line as an individual commit.
split_commits = false
# An array of regex based parsers to modify commit messages prior to further processing.
commit_preprocessors = [
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit message using https://github.com/crate-ci/typos.
# If the spelling is incorrect, it will be fixed automatically.
#{ pattern = '.*', replace_command = 'typos --write-changes -' }
]
# Prevent commits that are breaking from being excluded by commit parsers.
protect_breaking_commits = false
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^[Cc]hore\\([Rr]elease\\): prepare for", skip = true },
{ message = "(^[Mm]erge)|([Mm]erge conflict)", skip = true },
{ field = "author.name", pattern = "dependabot*", group = "<!-- 0A -->Updates" },
{ message = "([Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ body = "(.*[Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ message = "([Cc]hore\\(lint\\))|(style)|(lint)|(codeql)|(golangci)", group = "<!-- 05 -->Code quality" },
{ message = "(^[Dd]oc)|((?i)readme)|(badge)|(typo)|(documentation)", group = "<!-- 03 -->Documentation" },
{ message = "(^[Ff]eat)|(^[Ee]nhancement)", group = "<!-- 00 -->Implemented enhancements" },
{ message = "(^ci)|(\\(ci\\))|(fixup\\s+ci)|(fix\\s+ci)|(license)|(example)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^test", group = "<!-- 06 -->Testing" },
{ message = "(^fix)|(panic)", group = "<!-- 01 -->Fixed bugs" },
{ message = "(^refact)|(rework)", group = "<!-- 02 -->Refactor" },
{ message = "(^[Pp]erf)|(performance)", group = "<!-- 04 -->Performance" },
{ message = "(^[Cc]hore)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^[Rr]evert", group = "<!-- 09 -->Reverted changes" },
{ message = "(upgrade.*?go)|(go\\s+version)", group = "<!-- 0A -->Updates" },
{ message = ".*", group = "<!-- 0B -->Other" },
]
# Exclude commits that are not matched by any commit parser.
filter_commits = false
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
link_parsers = []
# Include only the tags that belong to the current branch.
use_branch_tags = false
# Order releases topologically instead of chronologically.
topo_order = false
# Order releases topologically instead of chronologically.
topo_order_commits = true
# Order of commits in each group/release within the changelog.
# Allowed values: newest, oldest
sort_commits = "newest"
# Process submodules commits
recurse_submodules = false
#[remote.github]
#owner = "go-openapi"
+6 -1
View File
@@ -1 +1,6 @@
secrets.yml
*.out
*.cov
.idea
.env
.mcp.json
.claude/
+1
View File
@@ -12,6 +12,7 @@ linters:
- paralleltest
- recvcheck
- testpackage
- thelper
- tparallel
- varnamelen
- whitespace
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+2 -2
View File
@@ -4,11 +4,11 @@
| Total Contributors | Total Contributions |
| --- | --- |
| 9 | 68 |
| 9 | 73 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @fredbi | 31 | https://github.com/go-openapi/jsonreference/commits?author=fredbi |
| @fredbi | 36 | https://github.com/go-openapi/jsonreference/commits?author=fredbi |
| @casualjim | 25 | https://github.com/go-openapi/jsonreference/commits?author=casualjim |
| @youyuanwu | 5 | https://github.com/go-openapi/jsonreference/commits?author=youyuanwu |
| @olivierlemasle | 2 | https://github.com/go-openapi/jsonreference/commits?author=olivierlemasle |
+2 -2
View File
@@ -3,7 +3,7 @@ Copyright 2015-2025 go-swagger maintainers
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
This software library, github.com/go-openapi/jsonpointer, includes software developed
This software library, github.com/go-openapi/jsonreference, includes software developed
by the go-swagger and go-openapi maintainers ("go-swagger maintainers").
Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,7 @@ It ships with copies of other software which license terms are recalled below.
The original software was authored on 25-02-2013 by sigu-399 (https://github.com/sigu-399, sigu.399@gmail.com).
github.com/sigh-399/jsonpointer
github.com/sigh-399/jsonreference
===========================
// SPDX-FileCopyrightText: Copyright 2013 sigu-399 ( https://github.com/sigu-399 )
+32 -4
View File
@@ -8,12 +8,22 @@
[![Release][release-badge]][release-url] [![Go Report Card][gocard-badge]][gocard-url] [![CodeFactor Grade][codefactor-badge]][codefactor-url] [![License][license-badge]][license-url]
<!-- Badges: documentation & support -->
<!-- Badges: others & stats -->
[![GoDoc][godoc-badge]][godoc-url] [![Slack Channel][slack-logo]![slack-badge]][slack-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
[![GoDoc][godoc-badge]][godoc-url] [![Discord Channel][discord-badge]][discord-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
---
An implementation of JSON Reference for golang.
## Announcements
* **2025-12-19** : new community chat on discord
* a new discord community channel is available to be notified of changes and support users
* our venerable Slack channel remains open, and will be eventually discontinued on **2026-03-31**
You may join the discord community by clicking the invite link on the discord badge (also above). [![Discord Channel][discord-badge]][discord-url]
Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url]
## Status
API is stable.
@@ -26,18 +36,33 @@ go get github.com/go-openapi/jsonreference
## Dependencies
* https://github.com/go-openapi/jsonpointer
* <https://github.com/go-openapi/jsonpointer>
## Basic usage
```go
// Creating a new reference
ref, err := jsonreference.New("http://example.com/doc.json#/definitions/Pet")
// Fragment-only reference
fragRef := jsonreference.MustCreateRef("#/definitions/Pet")
// Resolving references
parent, _ := jsonreference.New("http://example.com/base.json")
child, _ := jsonreference.New("#/definitions/Pet")
resolved, _ := parent.Inherits(child)
// Result: "http://example.com/base.json#/definitions/Pet"
```
## Change log
See <https://github.com/go-openapi/jsonreference/releases>
## References
* http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
* http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
* <http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07>
* <http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03>
## Licensing
@@ -89,6 +114,9 @@ Maintainers can cut a new release by either:
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: https://github.com/go-openapi/jsonreference/?tab=Apache-2.0-1-ov-file#readme
+23 -5
View File
@@ -6,14 +6,32 @@ This policy outlines the commitment and practices of the go-openapi maintainers
| Version | Supported |
| ------- | ------------------ |
| 0.22.x | :white_check_mark: |
| O.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
please report it privately to the maintainers.
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to
[Privately report a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
TL;DR: on Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
+1
View File
@@ -16,6 +16,7 @@ const (
fragmentRune = `#`
)
// ErrChildURL is raised when there is no child.
var ErrChildURL = errors.New("child url is nil")
// Ref represents a json reference object.
+5 -4
View File
@@ -1,4 +1,5 @@
secrets.yml
coverage.out
profile.cov
profile.out
*.out
*.cov
.idea
.env
.mcp.json
+11 -17
View File
@@ -2,25 +2,12 @@ version: "2"
linters:
default: all
disable:
- cyclop
- depguard
- errchkjson
- errorlint
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoglobals # on this repo, it is hard to refactor without globals/inits and no breaking change
- gochecknoinits
- gocognit
- godot
- godox
- gosmopolitan
- inamedparam
- intrange
- ireturn
- lll
- musttag
- nestif
- exhaustruct
- nlreturn
- nonamedreturns
- noinlineerr
@@ -29,7 +16,6 @@ linters:
- testpackage
- thelper
- tparallel
- unparam
- varnamelen
- whitespace
- wrapcheck
@@ -41,8 +27,15 @@ linters:
goconst:
min-len: 2
min-occurrences: 3
cyclop:
max-complexity: 20
gocyclo:
min-complexity: 45
min-complexity: 20
exhaustive:
default-signifies-exhaustive: true
default-case-required: true
lll:
line-length: 180
exclusions:
generated: lax
presets:
@@ -58,6 +51,7 @@ formatters:
enable:
- gofmt
- goimports
- gofumpt
exclusions:
generated: lax
paths:
-25
View File
@@ -1,25 +0,0 @@
after_success:
- bash <(curl -s https://codecov.io/bash)
go:
- 1.16.x
- 1.x
install:
- go get gotest.tools/gotestsum
language: go
arch:
- amd64
- ppc64le
jobs:
include:
# include linting job, but only for latest go version and amd64 arch
- go: 1.x
arch: amd64
install:
go get github.com/golangci/golangci-lint/cmd/golangci-lint
script:
- golangci-lint run --new-from-rev master
notifications:
slack:
secure: OxkPwVp35qBTUilgWC8xykSj+sGMcj0h8IIOKD+Rflx2schZVlFfdYdyVBM+s9OqeOfvtuvnR9v1Ye2rPKAvcjWdC4LpRGUsgmItZaI6Um8Aj6+K9udCw5qrtZVfOVmRu8LieH//XznWWKdOultUuniW0MLqw5+II87Gd00RWbCGi0hk0PykHe7uK+PDA2BEbqyZ2WKKYCvfB3j+0nrFOHScXqnh0V05l2E83J4+Sgy1fsPy+1WdX58ZlNBG333ibaC1FS79XvKSmTgKRkx3+YBo97u6ZtUmJa5WZjf2OdLG3KIckGWAv6R5xgxeU31N0Ng8L332w/Edpp2O/M2bZwdnKJ8hJQikXIAQbICbr+lTDzsoNzMdEIYcHpJ5hjPbiUl3Bmd+Jnsjf5McgAZDiWIfpCKZ29tPCEkVwRsOCqkyPRMNMzHHmoja495P5jR+ODS7+J8RFg5xgcnOgpP9D4Wlhztlf5WyZMpkLxTUD+bZq2SRf50HfHFXTkfq22zPl3d1eq0yrLwh/Z/fWKkfb6SyysROL8y6s8u3dpFX1YHSg0BR6i913h4aoZw9B2BG27cafLLTwKYsp2dFo1PWl4O6u9giFJIeqwloZHLKKrwh0cBFhB7RH0I58asxkZpCH6uWjJierahmHe7iS+E6i+9oCHkOZ59hmCYNimIs3hM=
script:
- gotestsum -f short-verbose -- -race -timeout=20m -coverprofile=coverage.txt -covermode=atomic ./...
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+26
View File
@@ -0,0 +1,26 @@
# Contributors
- Repository: ['go-openapi/loads']
| Total Contributors | Total Contributions |
| --- | --- |
| 14 | 123 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @casualjim | 48 | <https://github.com/go-openapi/loads/commits?author=casualjim> |
| @fredbi | 45 | <https://github.com/go-openapi/loads/commits?author=fredbi> |
| @youyuanwu | 6 | <https://github.com/go-openapi/loads/commits?author=youyuanwu> |
| @vburenin | 4 | <https://github.com/go-openapi/loads/commits?author=vburenin> |
| @keramix | 4 | <https://github.com/go-openapi/loads/commits?author=keramix> |
| @orisano | 3 | <https://github.com/go-openapi/loads/commits?author=orisano> |
| @GlenDC | 3 | <https://github.com/go-openapi/loads/commits?author=GlenDC> |
| @pengsrc | 2 | <https://github.com/go-openapi/loads/commits?author=pengsrc> |
| @a2800276 | 2 | <https://github.com/go-openapi/loads/commits?author=a2800276> |
| @tklauser | 2 | <https://github.com/go-openapi/loads/commits?author=tklauser> |
| @hypnoglow | 1 | <https://github.com/go-openapi/loads/commits?author=hypnoglow> |
| @koron | 1 | <https://github.com/go-openapi/loads/commits?author=koron> |
| @kreativka | 1 | <https://github.com/go-openapi/loads/commits?author=kreativka> |
| @petrkotas | 1 | <https://github.com/go-openapi/loads/commits?author=petrkotas> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_
+91 -5
View File
@@ -1,11 +1,42 @@
# Loads OAI specs [![Build Status](https://github.com/go-openapi/loads/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/loads/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/loads/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/loads)
# Loads OAI specs
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/loads/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/loads?status.svg)](http://godoc.org/github.com/go-openapi/loads)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-openapi/loads)](https://goreportcard.com/report/github.com/go-openapi/loads)
<!-- Badges: status -->
[![Tests][test-badge]][test-url] [![Coverage][cov-badge]][cov-url] [![CI vuln scan][vuln-scan-badge]][vuln-scan-url] [![CodeQL][codeql-badge]][codeql-url]
<!-- Badges: release & docker images -->
<!-- Badges: code quality -->
<!-- Badges: license & compliance -->
[![Release][release-badge]][release-url] [![Go Report Card][gocard-badge]][gocard-url] [![CodeFactor Grade][codefactor-badge]][codefactor-url] [![License][license-badge]][license-url]
<!-- Badges: documentation & support -->
<!-- Badges: others & stats -->
[![GoDoc][godoc-badge]][godoc-url] [![Discord Channel][discord-badge]][discord-url] [![go version][goversion-badge]][goversion-url] ![Top language][top-badge] ![Commits since latest release][commits-badge]
Loading of OAI v2 API specification documents from local or remote locations. Supports JSON and YAML documents.
---
Primary usage:
Loads OAI v2 API specification documents from local or remote locations.
Supports JSON and YAML documents.
## Announcements
* **2025-12-19** : new community chat on discord
* a new discord community channel is available to be notified of changes and support users
* our venerable Slack channel remains open, and will be eventually discontinued on **2026-03-31**
You may join the discord community by clicking the invite link on the discord badge (also above). [![Discord Channel][discord-badge]][discord-url]
Or join our Slack channel: [![Slack Channel][slack-logo]![slack-badge]][slack-url]
## Status
API is stable.
## Import this library in your project
```cmd
go get github.com/go-openapi/loads
```
## Basic usage
```go
import (
@@ -27,6 +58,61 @@ Primary usage:
See also the provided [examples](https://pkg.go.dev/github.com/go-openapi/loads#pkg-examples).
## Change log
See <https://github.com/go-openapi/loads/releases>
## Licensing
This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE).
## Other documentation
* [All-time contributors](./CONTRIBUTORS.md)
* [Contributing guidelines](.github/CONTRIBUTING.md)
* [Maintainers documentation](docs/MAINTAINERS.md)
* [Code style](docs/STYLE.md)
## Cutting a new release
Maintainers can cut a new release by either:
* running [this workflow](https://github.com/go-openapi/loads/actions/workflows/bump-release.yml)
* or pushing a semver tag
* signed tags are preferred
* The tag message is prepended to release notes
<!-- Badges: status -->
[test-badge]: https://github.com/go-openapi/loads/actions/workflows/go-test.yml/badge.svg
[test-url]: https://github.com/go-openapi/loads/actions/workflows/go-test.yml
[cov-badge]: https://codecov.io/gh/go-openapi/loads/branch/master/graph/badge.svg
[cov-url]: https://codecov.io/gh/go-openapi/loads
[vuln-scan-badge]: https://github.com/go-openapi/loads/actions/workflows/scanner.yml/badge.svg
[vuln-scan-url]: https://github.com/go-openapi/loads/actions/workflows/scanner.yml
[codeql-badge]: https://github.com/go-openapi/loads/actions/workflows/codeql.yml/badge.svg
[codeql-url]: https://github.com/go-openapi/loads/actions/workflows/codeql.yml
<!-- Badges: release & docker images -->
[release-badge]: https://badge.fury.io/gh/go-openapi%2Floads.svg
[release-url]: https://badge.fury.io/gh/go-openapi%2Floads
<!-- Badges: code quality -->
[gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/loads
[gocard-url]: https://goreportcard.com/report/github.com/go-openapi/loads
[codefactor-badge]: https://img.shields.io/codefactor/grade/github/go-openapi/loads
[codefactor-url]: https://www.codefactor.io/repository/github/go-openapi/loads
<!-- Badges: documentation & support -->
[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/loads
[godoc-url]: http://pkg.go.dev/github.com/go-openapi/loads
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: https://github.com/go-openapi/loads/?tab=Apache-2.0-1-ov-file#readme
<!-- Badges: others & stats -->
[goversion-badge]: https://img.shields.io/github/go-mod/go-version/go-openapi/loads
[goversion-url]: https://github.com/go-openapi/loads/blob/master/go.mod
[top-badge]: https://img.shields.io/github/languages/top/go-openapi/loads
[commits-badge]: https://img.shields.io/github/commits-since/go-openapi/loads/latest
+37
View File
@@ -0,0 +1,37 @@
# Security Policy
This policy outlines the commitment and practices of the go-openapi maintainers regarding security.
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 0.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
+2
View File
@@ -4,4 +4,6 @@
// Package loads provides document loading methods for swagger (OAI v2) API specifications.
//
// It is used by other go-openapi packages to load and run analysis on local or remote spec documents.
//
// Loaders support JSON and YAML documents.
package loads
+2 -2
View File
@@ -10,9 +10,9 @@ func (e loaderError) Error() string {
}
const (
// ErrLoads is an error returned by the loads package
// ErrLoads is an error returned by the loads package.
ErrLoads loaderError = "loaderrs error"
// ErrNoLoader indicates that no configured loader matched the input
// ErrNoLoader indicates that no configured loader matched the input.
ErrNoLoader loaderError = "no loader matched"
)
+18 -19
View File
@@ -13,14 +13,12 @@ import (
"github.com/go-openapi/swag/loading"
)
var (
// Default chain of loaders, defined at the package level.
//
// By default this matches json and yaml documents.
//
// May be altered with AddLoader().
loaders *loader
)
// Default chain of loaders, defined at the package level.
//
// By default this matches json and yaml documents.
//
// May be altered with AddLoader().
var loaders *loader
func init() {
jsonLoader := &loader{
@@ -43,10 +41,10 @@ func init() {
spec.PathLoader = loaders.Load
}
// DocLoader represents a doc loader type
// DocLoader represents a doc loader type.
type DocLoader func(string, ...loading.Option) (json.RawMessage, error)
// DocMatcher represents a predicate to check if a loader matches
// DocMatcher represents a predicate to check if a loader matches.
type DocMatcher func(string) bool
// DocLoaderWithMatch describes a loading function for a given extension match.
@@ -55,7 +53,7 @@ type DocLoaderWithMatch struct {
Match DocMatcher
}
// NewDocLoaderWithMatch builds a DocLoaderWithMatch to be used in load options
// NewDocLoaderWithMatch builds a [DocLoaderWithMatch] to be used in load options.
func NewDocLoaderWithMatch(fn DocLoader, matcher DocMatcher) DocLoaderWithMatch {
return DocLoaderWithMatch{
Fn: fn,
@@ -71,7 +69,7 @@ type loader struct {
Next *loader
}
// WithHead adds a loader at the head of the current stack
// WithHead adds a loader at the head of the current stack.
func (l *loader) WithHead(head *loader) *loader {
if head == nil {
return l
@@ -80,13 +78,13 @@ func (l *loader) WithHead(head *loader) *loader {
return head
}
// WithNext adds a loader at the trail of the current stack
// WithNext adds a loader at the trail of the current stack.
func (l *loader) WithNext(next *loader) *loader {
l.Next = next
return next
}
// Load the raw document from path
// Load the raw document from path.
func (l *loader) Load(path string) (json.RawMessage, error) {
_, erp := url.Parse(path)
if erp != nil {
@@ -123,9 +121,9 @@ func (l *loader) clone() *loader {
}
}
// JSONDoc loads a json document from either a file or a remote url.
// JSONDoc loads a json document from either a file or a remote URL.
//
// See [loading.Option] for available options (e.g. configuring authentifaction,
// See [loading.Option] for available options (e.g. configuring authentication,
// headers or using embedded file system resources).
func JSONDoc(path string, opts ...loading.Option) (json.RawMessage, error) {
data, err := loading.LoadFromFileOrHTTP(path, opts...)
@@ -139,9 +137,10 @@ func JSONDoc(path string, opts ...loading.Option) (json.RawMessage, error) {
//
// This sets the configuration at the package level.
//
// NOTE:
// - this updates the default loader used by github.com/go-openapi/spec
// - since this sets package level globals, you shouln't call this concurrently
// # Concurrency
//
// This function updates the default loader used by [github.com/go-openapi/spec].
// Since this sets package level globals, you shouldn't call this concurrently.
func AddLoader(predicate DocMatcher, load DocLoader) {
loaders = loaders.WithHead(&loader{
DocLoaderWithMatch: DocLoaderWithMatch{
+3 -3
View File
@@ -28,10 +28,10 @@ func loaderFromOptions(options []LoaderOption) *loader {
return l
}
// LoaderOption allows to fine-tune the spec loader behavior
// LoaderOption allows to fine-tune the spec loader behavior.
type LoaderOption func(*options)
// WithDocLoader sets a custom loader for loading specs
// WithDocLoader sets a custom loader for loading specs.
func WithDocLoader(l DocLoader) LoaderOption {
return func(opt *options) {
if l == nil {
@@ -48,7 +48,7 @@ func WithDocLoader(l DocLoader) LoaderOption {
// WithDocLoaderMatches sets a chain of custom loaders for loading specs
// for different extension matches.
//
// Loaders are executed in the order of provided DocLoaderWithMatch'es.
// Loaders are executed in the order of provided [DocLoaderWithMatch] 'es.
func WithDocLoaderMatches(l ...DocLoaderWithMatch) LoaderOption {
return func(opt *options) {
var final, prev *loader
+18 -18
View File
@@ -21,7 +21,7 @@ func init() {
gob.Register([]any{})
}
// Document represents a swagger spec document
// Document represents a swagger spec document.
type Document struct {
// specAnalyzer
Analyzer *analysis.Spec
@@ -33,7 +33,7 @@ type Document struct {
raw json.RawMessage
}
// JSONSpec loads a spec from a json document, using the [JSONDoc] loader.
// JSONSpec loads a spec from a JSON document, using the [JSONDoc] loader.
//
// A set of [loading.Option] may be passed to this loader using [WithLoadingOptions].
func JSONSpec(path string, opts ...LoaderOption) (*Document, error) {
@@ -57,7 +57,7 @@ func JSONSpec(path string, opts ...LoaderOption) (*Document, error) {
return doc, nil
}
// Embedded returns a Document based on embedded specs (i.e. as a raw [json.RawMessage]). No analysis is required
// Embedded returns a Document based on embedded specs (i.e. as a [json.RawMessage]). No analysis is required.
func Embedded(orig, flat json.RawMessage, opts ...LoaderOption) (*Document, error) {
var origSpec, flatSpec spec.Swagger
if err := json.Unmarshal(orig, &origSpec); err != nil {
@@ -96,7 +96,7 @@ func Spec(path string, opts ...LoaderOption) (*Document, error) {
return document, nil
}
// Analyzed creates a new analyzed spec document for a root json.RawMessage.
// Analyzed creates a new analyzed spec document for a root [json.RawMessage].
func Analyzed(data json.RawMessage, version string, options ...LoaderOption) (*Document, error) {
if version == "" {
version = "2.0"
@@ -145,18 +145,18 @@ func trimData(in json.RawMessage) (json.RawMessage, error) {
// assume yaml doc: convert it to json
yml, err := yamlutils.BytesToYAMLDoc(trimmed)
if err != nil {
return nil, fmt.Errorf("analyzed: %v: %w", err, ErrLoads)
return nil, fmt.Errorf("analyzed: %w: %w", err, ErrLoads)
}
d, err := yamlutils.YAMLToJSON(yml)
if err != nil {
return nil, fmt.Errorf("analyzed: %v: %w", err, ErrLoads)
return nil, fmt.Errorf("analyzed: %w: %w", err, ErrLoads)
}
return d, nil
}
// Expanded expands the $ref fields in the spec [Document] and returns a new expanded [Document]
// Expanded expands the $ref fields in the spec [Document] and returns a new expanded [Document].
func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) {
swspec := new(spec.Swagger)
if err := json.Unmarshal(d.raw, swspec); err != nil {
@@ -200,7 +200,7 @@ func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) {
return dd, nil
}
// BasePath the base path for the API specified by this spec
// BasePath the base path for the API specified by this spec.
func (d *Document) BasePath() string {
if d.spec == nil {
return ""
@@ -208,37 +208,37 @@ func (d *Document) BasePath() string {
return d.spec.BasePath
}
// Version returns the OpenAPI version of this spec (e.g. 2.0)
// Version returns the OpenAPI version of this spec (e.g. 2.0).
func (d *Document) Version() string {
return d.spec.Swagger
}
// Schema returns the swagger 2.0 meta-schema
// Schema returns the swagger 2.0 meta-schema.
func (d *Document) Schema() *spec.Schema {
return d.schema
}
// Spec returns the swagger object model for this API specification
// Spec returns the swagger object model for this API specification.
func (d *Document) Spec() *spec.Swagger {
return d.spec
}
// Host returns the host for the API
// Host returns the host for the API.
func (d *Document) Host() string {
return d.spec.Host
}
// Raw returns the raw swagger spec as json bytes
// Raw returns the raw swagger spec as json bytes.
func (d *Document) Raw() json.RawMessage {
return d.raw
}
// OrigSpec yields the original spec
// OrigSpec yields the original spec.
func (d *Document) OrigSpec() *spec.Swagger {
return d.origSpec
}
// ResetDefinitions yields a shallow copy with the models reset to the original spec
// ResetDefinitions yields a shallow copy with the models reset to the original spec.
func (d *Document) ResetDefinitions() *Document {
d.spec.Definitions = make(map[string]spec.Schema, len(d.origSpec.Definitions))
maps.Copy(d.spec.Definitions, d.origSpec.Definitions)
@@ -246,9 +246,9 @@ func (d *Document) ResetDefinitions() *Document {
return d
}
// Pristine creates a new pristine document instance based on the input data
// Pristine creates a new pristine document instance based on the input data.
func (d *Document) Pristine() *Document {
raw, _ := json.Marshal(d.Spec())
raw, _ := json.Marshal(d.Spec()) //nolint:errchkjson // the spec always marshals to JSON
dd, _ := Analyzed(raw, d.Version())
dd.pathLoader = d.pathLoader
dd.specFilePath = d.specFilePath
@@ -256,7 +256,7 @@ func (d *Document) Pristine() *Document {
return dd
}
// SpecFilePath returns the file path of the spec if one is defined
// SpecFilePath returns the file path of the spec if one is defined.
func (d *Document) SpecFilePath() string {
return d.specFilePath
}
-181
View File
@@ -1,181 +0,0 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[changelog]
header = """
"""
footer = """
-----
**[{{ remote.github.repo }}]({{ self::remote_url() }}) license terms**
[![License][license-badge]][license-url]
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
[license-url]: {{ self::remote_url() }}/?tab=Apache-2.0-1-ov-file#readme
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
body = """
{%- if version %}
## [{{ version | trim_start_matches(pat="v") }}]({{ self::remote_url() }}/tree/{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{%- else %}
## [unreleased]
{%- endif %}
{%- if message %}
{%- raw %}\n{% endraw %}
{{ message }}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if version %}
{%- if previous.version %}
**Full Changelog**: <{{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}>
{%- endif %}
{%- else %}
{%- raw %}\n{% endraw %}
{%- endif %}
{%- if statistics %}{% if statistics.commit_count %}
{%- raw %}\n{% endraw %}
{{ statistics.commit_count }} commits in this release.
{%- raw %}\n{% endraw %}
{%- endif %}{% endif %}
-----
{%- for group, commits in commits | group_by(attribute="group") %}
{%- raw %}\n{% endraw %}
### {{ group | upper_first }}
{%- raw %}\n{% endraw %}
{%- for commit in commits %}
{%- if commit.remote.pr_title %}
{%- set commit_message = commit.remote.pr_title %}
{%- else %}
{%- set commit_message = commit.message %}
{%- endif %}
* {{ commit_message | split(pat="\n") | first | trim }}
{%- if commit.remote.username %}
{%- raw %} {% endraw %}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})
{%- endif %}
{%- if commit.remote.pr_number %}
{%- raw %} {% endraw %}in [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }})
{%- endif %}
{%- raw %} {% endraw %}[...]({{ self::remote_url() }}/commit/{{ commit.id }})
{%- endfor %}
{%- endfor %}
{%- if github %}
{%- raw %}\n{% endraw -%}
{%- set all_contributors = github.contributors | length %}
{%- if github.contributors | filter(attribute="username", value="dependabot[bot]") | length < all_contributors %}
-----
### People who contributed to this release
{% endif %}
{%- for contributor in github.contributors | filter(attribute="username") | sort(attribute="username") %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }})
{%- endif %}
{%- endfor %}
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
-----
{%- raw %}\n{% endraw %}
### New Contributors
{%- endif %}
{%- for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
{%- if contributor.username != "dependabot[bot]" and contributor.username != "github-actions[bot]" %}
* @{{ contributor.username }} made their first contribution
{%- if contributor.pr_number %}
in [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- raw %}\n{% endraw %}
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
# Render body even when there are no releases to process.
render_always = true
# An array of regex based postprocessors to modify the changelog.
postprocessors = [
# Replace the placeholder <REPO> with a URL.
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
]
# output file path
# output = "test.md"
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
conventional_commits = false
# Exclude commits that do not match the conventional commits specification.
filter_unconventional = false
# Require all commits to be conventional.
# Takes precedence over filter_unconventional.
require_conventional = false
# Split commits on newlines, treating each line as an individual commit.
split_commits = false
# An array of regex based parsers to modify commit messages prior to further processing.
commit_preprocessors = [
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit message using https://github.com/crate-ci/typos.
# If the spelling is incorrect, it will be fixed automatically.
#{ pattern = '.*', replace_command = 'typos --write-changes -' }
]
# Prevent commits that are breaking from being excluded by commit parsers.
protect_breaking_commits = false
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^[Cc]hore\\([Rr]elease\\): prepare for", skip = true },
{ message = "(^[Mm]erge)|([Mm]erge conflict)", skip = true },
{ field = "author.name", pattern = "dependabot*", group = "<!-- 0A -->Updates" },
{ message = "([Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ body = "(.*[Ss]ecurity)|([Vv]uln)", group = "<!-- 08 -->Security" },
{ message = "([Cc]hore\\(lint\\))|(style)|(lint)|(codeql)|(golangci)", group = "<!-- 05 -->Code quality" },
{ message = "(^[Dd]oc)|((?i)readme)|(badge)|(typo)|(documentation)", group = "<!-- 03 -->Documentation" },
{ message = "(^[Ff]eat)|(^[Ee]nhancement)", group = "<!-- 00 -->Implemented enhancements" },
{ message = "(^ci)|(\\(ci\\))|(fixup\\s+ci)|(fix\\s+ci)|(license)|(example)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^test", group = "<!-- 06 -->Testing" },
{ message = "(^fix)|(panic)", group = "<!-- 01 -->Fixed bugs" },
{ message = "(^refact)|(rework)", group = "<!-- 02 -->Refactor" },
{ message = "(^[Pp]erf)|(performance)", group = "<!-- 04 -->Performance" },
{ message = "(^[Cc]hore)", group = "<!-- 07 -->Miscellaneous tasks" },
{ message = "^[Rr]evert", group = "<!-- 09 -->Reverted changes" },
{ message = "(upgrade.*?go)|(go\\s+version)", group = "<!-- 0A -->Updates" },
{ message = ".*", group = "<!-- 0B -->Other" },
]
# Exclude commits that are not matched by any commit parser.
filter_commits = false
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
link_parsers = []
# Include only the tags that belong to the current branch.
use_branch_tags = false
# Order releases topologically instead of chronologically.
topo_order = false
# Order releases topologically instead of chronologically.
topo_order_commits = true
# Order of commits in each group/release within the changelog.
# Allowed values: newest, oldest
sort_commits = "newest"
# Process submodules commits
recurse_submodules = false
#[remote.github]
#owner = "go-openapi"
+5
View File
@@ -1 +1,6 @@
*.out
*.cov
.idea
.env
.mcp.json
.claude/
+1
View File
@@ -12,6 +12,7 @@ linters:
- paralleltest
- recvcheck
- testpackage
- thelper
- tparallel
- varnamelen
- whitespace
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+39 -39
View File
@@ -4,47 +4,47 @@
| Total Contributors | Total Contributions |
| --- | --- |
| 38 | 391 |
| 38 | 392 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @casualjim | 191 | https://github.com/go-openapi/spec/commits?author=casualjim |
| @fredbi | 89 | https://github.com/go-openapi/spec/commits?author=fredbi |
| @pytlesk4 | 26 | https://github.com/go-openapi/spec/commits?author=pytlesk4 |
| @kul-amr | 10 | https://github.com/go-openapi/spec/commits?author=kul-amr |
| @keramix | 10 | https://github.com/go-openapi/spec/commits?author=keramix |
| @youyuanwu | 8 | https://github.com/go-openapi/spec/commits?author=youyuanwu |
| @pengsrc | 7 | https://github.com/go-openapi/spec/commits?author=pengsrc |
| @alphacentory | 5 | https://github.com/go-openapi/spec/commits?author=alphacentory |
| @mtfelian | 4 | https://github.com/go-openapi/spec/commits?author=mtfelian |
| @Capstan | 4 | https://github.com/go-openapi/spec/commits?author=Capstan |
| @sdghchj | 4 | https://github.com/go-openapi/spec/commits?author=sdghchj |
| @databus23 | 2 | https://github.com/go-openapi/spec/commits?author=databus23 |
| @vburenin | 2 | https://github.com/go-openapi/spec/commits?author=vburenin |
| @petrkotas | 2 | https://github.com/go-openapi/spec/commits?author=petrkotas |
| @nikhita | 2 | https://github.com/go-openapi/spec/commits?author=nikhita |
| @hypnoglow | 2 | https://github.com/go-openapi/spec/commits?author=hypnoglow |
| @carvind | 2 | https://github.com/go-openapi/spec/commits?author=carvind |
| @ujjwalsh | 1 | https://github.com/go-openapi/spec/commits?author=ujjwalsh |
| @mbohlool | 1 | https://github.com/go-openapi/spec/commits?author=mbohlool |
| @j2gg0s | 1 | https://github.com/go-openapi/spec/commits?author=j2gg0s |
| @ishveda | 1 | https://github.com/go-openapi/spec/commits?author=ishveda |
| @micln | 1 | https://github.com/go-openapi/spec/commits?author=micln |
| @GlenDC | 1 | https://github.com/go-openapi/spec/commits?author=GlenDC |
| @agmikhailov | 1 | https://github.com/go-openapi/spec/commits?author=agmikhailov |
| @tgraf | 1 | https://github.com/go-openapi/spec/commits?author=tgraf |
| @zhsj | 1 | https://github.com/go-openapi/spec/commits?author=zhsj |
| @sebastien-rosset | 1 | https://github.com/go-openapi/spec/commits?author=sebastien-rosset |
| @alexandear | 1 | https://github.com/go-openapi/spec/commits?author=alexandear |
| @morlay | 1 | https://github.com/go-openapi/spec/commits?author=morlay |
| @mikedanese | 1 | https://github.com/go-openapi/spec/commits?author=mikedanese |
| @koron | 1 | https://github.com/go-openapi/spec/commits?author=koron |
| @honza | 1 | https://github.com/go-openapi/spec/commits?author=honza |
| @gbjk | 1 | https://github.com/go-openapi/spec/commits?author=gbjk |
| @faguirre1 | 1 | https://github.com/go-openapi/spec/commits?author=faguirre1 |
| @ethantkoenig | 1 | https://github.com/go-openapi/spec/commits?author=ethantkoenig |
| @sttts | 1 | https://github.com/go-openapi/spec/commits?author=sttts |
| @ChandanChainani | 1 | https://github.com/go-openapi/spec/commits?author=ChandanChainani |
| @bvwells | 1 | https://github.com/go-openapi/spec/commits?author=bvwells |
| @casualjim | 191 | <https://github.com/go-openapi/spec/commits?author=casualjim> |
| @fredbi | 90 | <https://github.com/go-openapi/spec/commits?author=fredbi> |
| @pytlesk4 | 26 | <https://github.com/go-openapi/spec/commits?author=pytlesk4> |
| @kul-amr | 10 | <https://github.com/go-openapi/spec/commits?author=kul-amr> |
| @keramix | 10 | <https://github.com/go-openapi/spec/commits?author=keramix> |
| @youyuanwu | 8 | <https://github.com/go-openapi/spec/commits?author=youyuanwu> |
| @pengsrc | 7 | <https://github.com/go-openapi/spec/commits?author=pengsrc> |
| @alphacentory | 5 | <https://github.com/go-openapi/spec/commits?author=alphacentory> |
| @mtfelian | 4 | <https://github.com/go-openapi/spec/commits?author=mtfelian> |
| @Capstan | 4 | <https://github.com/go-openapi/spec/commits?author=Capstan> |
| @sdghchj | 4 | <https://github.com/go-openapi/spec/commits?author=sdghchj> |
| @databus23 | 2 | <https://github.com/go-openapi/spec/commits?author=databus23> |
| @vburenin | 2 | <https://github.com/go-openapi/spec/commits?author=vburenin> |
| @petrkotas | 2 | <https://github.com/go-openapi/spec/commits?author=petrkotas> |
| @nikhita | 2 | <https://github.com/go-openapi/spec/commits?author=nikhita> |
| @hypnoglow | 2 | <https://github.com/go-openapi/spec/commits?author=hypnoglow> |
| @carvind | 2 | <https://github.com/go-openapi/spec/commits?author=carvind> |
| @ujjwalsh | 1 | <https://github.com/go-openapi/spec/commits?author=ujjwalsh> |
| @mbohlool | 1 | <https://github.com/go-openapi/spec/commits?author=mbohlool> |
| @j2gg0s | 1 | <https://github.com/go-openapi/spec/commits?author=j2gg0s> |
| @ishveda | 1 | <https://github.com/go-openapi/spec/commits?author=ishveda> |
| @micln | 1 | <https://github.com/go-openapi/spec/commits?author=micln> |
| @GlenDC | 1 | <https://github.com/go-openapi/spec/commits?author=GlenDC> |
| @agmikhailov | 1 | <https://github.com/go-openapi/spec/commits?author=agmikhailov> |
| @tgraf | 1 | <https://github.com/go-openapi/spec/commits?author=tgraf> |
| @zhsj | 1 | <https://github.com/go-openapi/spec/commits?author=zhsj> |
| @sebastien-rosset | 1 | <https://github.com/go-openapi/spec/commits?author=sebastien-rosset> |
| @alexandear | 1 | <https://github.com/go-openapi/spec/commits?author=alexandear> |
| @morlay | 1 | <https://github.com/go-openapi/spec/commits?author=morlay> |
| @mikedanese | 1 | <https://github.com/go-openapi/spec/commits?author=mikedanese> |
| @koron | 1 | <https://github.com/go-openapi/spec/commits?author=koron> |
| @honza | 1 | <https://github.com/go-openapi/spec/commits?author=honza> |
| @gbjk | 1 | <https://github.com/go-openapi/spec/commits?author=gbjk> |
| @faguirre1 | 1 | <https://github.com/go-openapi/spec/commits?author=faguirre1> |
| @ethantkoenig | 1 | <https://github.com/go-openapi/spec/commits?author=ethantkoenig> |
| @sttts | 1 | <https://github.com/go-openapi/spec/commits?author=sttts> |
| @ChandanChainani | 1 | <https://github.com/go-openapi/spec/commits?author=ChandanChainani> |
| @bvwells | 1 | <https://github.com/go-openapi/spec/commits?author=bvwells> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github/contributors)_
+6 -6
View File
@@ -55,7 +55,7 @@ go get github.com/go-openapi/spec
> There is no plan to make it evolve toward supporting OpenAPI 3.x.
> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
>
> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3
> An early attempt to support Swagger 3 may be found at: <https://github.com/go-openapi/spec3>
* Does the unmarshaling support YAML?
@@ -64,13 +64,13 @@ go get github.com/go-openapi/spec
> In order to load a YAML document as a Swagger spec, you need to use the loaders provided by
> github.com/go-openapi/loads
>
> Take a look at the example there: https://pkg.go.dev/github.com/go-openapi/loads#example-Spec
> Take a look at the example there: <https://pkg.go.dev/github.com/go-openapi/loads#example-Spec>
>
> See also https://github.com/go-openapi/spec/issues/164
> See also <https://github.com/go-openapi/spec/issues/164>
* How can I validate a spec?
> Validation is provided by [the validate package](http://github.com/go-openapi/validate)
Validation is provided by [the validate package](http://github.com/go-openapi/validate)
* Why do we have an `ID` field for `Schema` which is not part of the swagger spec?
@@ -78,7 +78,7 @@ go get github.com/go-openapi/spec
> how `$ref` are resolved.
> This `id` does not conflict with any property named `id`.
>
> See also https://github.com/go-openapi/spec/issues/23
> See also <https://github.com/go-openapi/spec/issues/23>
## Change log
@@ -136,7 +136,7 @@ Maintainers can cut a new release by either:
[slack-badge]: https://img.shields.io/badge/slack-blue?link=https%3A%2F%2Fgoswagger.slack.com%2Farchives%2FC04R30YM
[slack-url]: https://goswagger.slack.com/archives/C04R30YMU
[discord-badge]: https://img.shields.io/discord/1446918742398341256?logo=discord&label=discord&color=blue
[discord-url]: https://discord.gg/DrafRmZx
[discord-url]: https://discord.gg/twZ9BwT3
<!-- Badges: license & compliance -->
[license-badge]: http://img.shields.io/badge/license-Apache%20v2-orange.svg
+23 -5
View File
@@ -6,14 +6,32 @@ This policy outlines the commitment and practices of the go-openapi maintainers
| Version | Supported |
| ------- | ------------------ |
| 0.22.x | :white_check_mark: |
| O.x | :white_check_mark: |
## Vulnerability checks in place
This repository uses automated vulnerability scans, at every merged commit and at least once a week.
We use:
* [`GitHub CodeQL`][codeql-url]
* [`trivy`][trivy-url]
* [`govulncheck`][govulncheck-url]
Reports are centralized in github security reports and visible only to the maintainers.
## Reporting a vulnerability
If you become aware of a security vulnerability that affects the current repository,
please report it privately to the maintainers.
**please report it privately to the maintainers**
rather than opening a publicly visible GitHub issue.
Please follow the instructions provided by github to
[Privately report a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability).
Please follow the instructions provided by github to [Privately report a security vulnerability][github-guidance-url].
TL;DR: on Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
> [!NOTE]
> On Github, navigate to the project's "Security" tab then click on "Report a vulnerability".
[codeql-url]: https://github.com/github/codeql
[trivy-url]: https://trivy.dev/docs/latest/getting-started
[govulncheck-url]: https://go.dev/blog/govulncheck
[github-guidance-url]: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability
+9 -9
View File
@@ -8,10 +8,10 @@ import (
"sync"
)
// ResolutionCache a cache for resolving urls
// ResolutionCache a cache for resolving urls.
type ResolutionCache interface {
Get(string) (any, bool)
Set(string, any)
Get(uri string) (any, bool)
Set(uri string, data any)
}
type simpleCache struct {
@@ -19,7 +19,7 @@ type simpleCache struct {
store map[string]any
}
func (s *simpleCache) ShallowClone() ResolutionCache {
func (s *simpleCache) ShallowClone() ResolutionCache { //nolint:ireturn // returns the public interface type by design
store := make(map[string]any, len(s.store))
s.lock.RLock()
maps.Copy(store, s.store)
@@ -30,7 +30,7 @@ func (s *simpleCache) ShallowClone() ResolutionCache {
}
}
// Get retrieves a cached URI
// Get retrieves a cached URI.
func (s *simpleCache) Get(uri string) (any, bool) {
s.lock.RLock()
v, ok := s.store[uri]
@@ -39,7 +39,7 @@ func (s *simpleCache) Get(uri string) (any, bool) {
return v, ok
}
// Set caches a URI
// Set caches a URI.
func (s *simpleCache) Set(uri string, data any) {
s.lock.Lock()
s.store[uri] = data
@@ -56,8 +56,8 @@ var (
//
// All subsequent utilizations of this cache are produced from a shallow
// clone of this initial version.
resCache *simpleCache
onceCache sync.Once
resCache *simpleCache //nolint:gochecknoglobals // package-level lazy cache for $ref resolution
onceCache sync.Once //nolint:gochecknoglobals // guards lazy init of resCache
_ ResolutionCache = &simpleCache{}
)
@@ -74,7 +74,7 @@ func defaultResolutionCache() *simpleCache {
}}
}
func cacheOrDefault(cache ResolutionCache) ResolutionCache {
func cacheOrDefault(cache ResolutionCache) ResolutionCache { //nolint:ireturn // returns the public interface type by design
onceCache.Do(initResolutionCache)
if cache != nil {
+3 -3
View File
@@ -17,14 +17,14 @@ type ContactInfo struct {
VendorExtensible
}
// ContactInfoProps hold the properties of a ContactInfo object
// ContactInfoProps hold the properties of a ContactInfo object.
type ContactInfoProps struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
// UnmarshalJSON hydrates ContactInfo from json
// UnmarshalJSON hydrates ContactInfo from json.
func (c *ContactInfo) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &c.ContactInfoProps); err != nil {
return err
@@ -32,7 +32,7 @@ func (c *ContactInfo) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &c.VendorExtensible)
}
// MarshalJSON produces ContactInfo as json
// MarshalJSON produces ContactInfo as json.
func (c ContactInfo) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(c.ContactInfoProps)
if err != nil {
+4 -6
View File
@@ -14,14 +14,12 @@ import (
// Debug is true when the SWAGGER_DEBUG env var is not empty.
//
// It enables a more verbose logging of this package.
var Debug = os.Getenv("SWAGGER_DEBUG") != ""
var Debug = os.Getenv("SWAGGER_DEBUG") != "" //nolint:gochecknoglobals // public toggle for debug logging
var (
// specLogger is a debug logger for this package
specLogger *log.Logger
)
// specLogger is a debug logger for this package.
var specLogger *log.Logger //nolint:gochecknoglobals // package-level debug logger
func init() {
func init() { //nolint:gochecknoinits // initializes debug logger at package load
debugOptions()
}
+6 -6
View File
@@ -5,21 +5,21 @@ package spec
import "errors"
// Error codes
// Error codes.
var (
// ErrUnknownTypeForReference indicates that a resolved reference was found in an unsupported container type
// ErrUnknownTypeForReference indicates that a resolved reference was found in an unsupported container type.
ErrUnknownTypeForReference = errors.New("unknown type for the resolved reference")
// ErrResolveRefNeedsAPointer indicates that a $ref target must be a valid JSON pointer
// ErrResolveRefNeedsAPointer indicates that a $ref target must be a valid JSON pointer.
ErrResolveRefNeedsAPointer = errors.New("resolve ref: target needs to be a pointer")
// ErrDerefUnsupportedType indicates that a resolved reference was found in an unsupported container type.
// At the moment, $ref are supported only inside: schemas, parameters, responses, path items
// At the moment, $ref are supported only inside: schemas, parameters, responses, path items.
ErrDerefUnsupportedType = errors.New("deref: unsupported type")
// ErrExpandUnsupportedType indicates that $ref expansion is attempted on some invalid type
// ErrExpandUnsupportedType indicates that $ref expansion is attempted on some invalid type.
ErrExpandUnsupportedType = errors.New("expand: unsupported type. Input should be of type *Parameter or *Response")
// ErrSpec is an error raised by the spec package
// ErrSpec is an error raised by the spec package.
ErrSpec = errors.New("spec error")
)
+6 -5
View File
@@ -38,7 +38,7 @@ func optionsOrDefault(opts *ExpandOptions) *ExpandOptions {
return &ExpandOptions{}
}
// ExpandSpec expands the references in a swagger spec
// ExpandSpec expands the references in a swagger spec.
func ExpandSpec(spec *Swagger, options *ExpandOptions) error {
options = optionsOrDefault(options)
resolver := defaultSchemaLoader(spec, options, nil, nil)
@@ -92,7 +92,7 @@ func ExpandSpec(spec *Swagger, options *ExpandOptions) error {
const rootBase = ".root"
// baseForRoot loads in the cache the root document and produces a fake ".root" base path entry
// for further $ref resolution
// for further $ref resolution.
func baseForRoot(root any, cache ResolutionCache) string {
// cache the root document to resolve $ref's
normalizedBase := normalizeBase(rootBase)
@@ -190,6 +190,7 @@ func expandItems(target Schema, parentRefs []string, resolver *schemaLoader, bas
return &target, nil
}
//nolint:gocognit,gocyclo,cyclop // complex but well-tested $ref expansion logic; refactoring deferred to dedicated PR
func expandSchema(target Schema, parentRefs []string, resolver *schemaLoader, basePath string) (*Schema, error) {
if target.Ref.String() == "" && target.Ref.IsRoot() {
newRef := normalizeRef(&target.Ref, basePath)
@@ -464,7 +465,7 @@ func ExpandResponseWithRoot(response *Response, root any, cache ResolutionCache)
// ExpandResponse expands a response based on a basepath
//
// All refs inside response will be resolved relative to basePath
// All refs inside response will be resolved relative to basePath.
func ExpandResponse(response *Response, basePath string) error {
opts := optionsOrDefault(&ExpandOptions{
RelativeBase: basePath,
@@ -491,7 +492,7 @@ func ExpandParameterWithRoot(parameter *Parameter, root any, cache ResolutionCac
// ExpandParameter expands a parameter based on a basepath.
// This is the exported version of expandParameter
// all refs inside parameter will be resolved relative to basePath
// all refs inside parameter will be resolved relative to basePath.
func ExpandParameter(parameter *Parameter, basePath string) error {
opts := optionsOrDefault(&ExpandOptions{
RelativeBase: basePath,
@@ -565,7 +566,7 @@ func expandParameterOrResponse(input any, resolver *schemaLoader, basePath strin
return nil
}
if sch.Ref.String() != "" {
if sch.Ref.String() != "" { //nolint:nestif // intertwined ref rebasing and circularity check
rebasedRef, ern := NewRef(normalizeURI(sch.Ref.String(), basePath))
if ern != nil {
return ern
+21 -21
View File
@@ -15,7 +15,7 @@ const (
jsonArray = "array"
)
// HeaderProps describes a response header
// HeaderProps describes a response header.
type HeaderProps struct {
Description string `json:"description,omitempty"`
}
@@ -30,25 +30,25 @@ type Header struct {
HeaderProps
}
// ResponseHeader creates a new header instance for use in a response
// ResponseHeader creates a new header instance for use in a response.
func ResponseHeader() *Header {
return new(Header)
}
// WithDescription sets the description on this response, allows for chaining
// WithDescription sets the description on this response, allows for chaining.
func (h *Header) WithDescription(description string) *Header {
h.Description = description
return h
}
// Typed a fluent builder method for the type of parameter
// Typed a fluent builder method for the type of parameter.
func (h *Header) Typed(tpe, format string) *Header {
h.Type = tpe
h.Format = format
return h
}
// CollectionOf a fluent builder method for an array item
// CollectionOf a fluent builder method for an array item.
func (h *Header) CollectionOf(items *Items, format string) *Header {
h.Type = jsonArray
h.Items = items
@@ -56,87 +56,87 @@ func (h *Header) CollectionOf(items *Items, format string) *Header {
return h
}
// WithDefault sets the default value on this item
// WithDefault sets the default value on this item.
func (h *Header) WithDefault(defaultValue any) *Header {
h.Default = defaultValue
return h
}
// WithMaxLength sets a max length value
// WithMaxLength sets a max length value.
func (h *Header) WithMaxLength(maximum int64) *Header {
h.MaxLength = &maximum
return h
}
// WithMinLength sets a min length value
// WithMinLength sets a min length value.
func (h *Header) WithMinLength(minimum int64) *Header {
h.MinLength = &minimum
return h
}
// WithPattern sets a pattern value
// WithPattern sets a pattern value.
func (h *Header) WithPattern(pattern string) *Header {
h.Pattern = pattern
return h
}
// WithMultipleOf sets a multiple of value
// WithMultipleOf sets a multiple of value.
func (h *Header) WithMultipleOf(number float64) *Header {
h.MultipleOf = &number
return h
}
// WithMaximum sets a maximum number value
// WithMaximum sets a maximum number value.
func (h *Header) WithMaximum(maximum float64, exclusive bool) *Header {
h.Maximum = &maximum
h.ExclusiveMaximum = exclusive
return h
}
// WithMinimum sets a minimum number value
// WithMinimum sets a minimum number value.
func (h *Header) WithMinimum(minimum float64, exclusive bool) *Header {
h.Minimum = &minimum
h.ExclusiveMinimum = exclusive
return h
}
// WithEnum sets a the enum values (replace)
// WithEnum sets a the enum values (replace).
func (h *Header) WithEnum(values ...any) *Header {
h.Enum = append([]any{}, values...)
return h
}
// WithMaxItems sets the max items
// WithMaxItems sets the max items.
func (h *Header) WithMaxItems(size int64) *Header {
h.MaxItems = &size
return h
}
// WithMinItems sets the min items
// WithMinItems sets the min items.
func (h *Header) WithMinItems(size int64) *Header {
h.MinItems = &size
return h
}
// UniqueValues dictates that this array can only have unique items
// UniqueValues dictates that this array can only have unique items.
func (h *Header) UniqueValues() *Header {
h.UniqueItems = true
return h
}
// AllowDuplicates this array can have duplicates
// AllowDuplicates this array can have duplicates.
func (h *Header) AllowDuplicates() *Header {
h.UniqueItems = false
return h
}
// WithValidations is a fluent method to set header validations
// WithValidations is a fluent method to set header validations.
func (h *Header) WithValidations(val CommonValidations) *Header {
h.SetValidations(SchemaValidations{CommonValidations: val})
return h
}
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (h Header) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(h.CommonValidations)
if err != nil {
@@ -153,7 +153,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2, b3), nil
}
// UnmarshalJSON unmarshals this header from JSON
// UnmarshalJSON unmarshals this header from JSON.
func (h *Header) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &h.CommonValidations); err != nil {
return err
@@ -167,7 +167,7 @@ func (h *Header) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &h.HeaderProps)
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (h Header) JSONLookup(token string) (any, error) {
if ex, ok := h.Extensions[token]; ok {
return &ex, nil
+13 -13
View File
@@ -12,16 +12,16 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// Extensions vendor specific extensions
// Extensions vendor specific extensions.
type Extensions map[string]any
// Add adds a value to these extensions
// Add adds a value to these extensions.
func (e Extensions) Add(key string, value any) {
realKey := strings.ToLower(key)
e[realKey] = value
}
// GetString gets a string value from the extensions
// GetString gets a string value from the extensions.
func (e Extensions) GetString(key string) (string, bool) {
if v, ok := e[strings.ToLower(key)]; ok {
str, ok := v.(string)
@@ -30,7 +30,7 @@ func (e Extensions) GetString(key string) (string, bool) {
return "", false
}
// GetInt gets a int value from the extensions
// GetInt gets a int value from the extensions.
func (e Extensions) GetInt(key string) (int, bool) {
realKey := strings.ToLower(key)
@@ -48,7 +48,7 @@ func (e Extensions) GetInt(key string) (int, bool) {
return -1, false
}
// GetBool gets a string value from the extensions
// GetBool gets a string value from the extensions.
func (e Extensions) GetBool(key string) (bool, bool) {
if v, ok := e[strings.ToLower(key)]; ok {
str, ok := v.(bool)
@@ -57,7 +57,7 @@ func (e Extensions) GetBool(key string) (bool, bool) {
return false, false
}
// GetStringSlice gets a string value from the extensions
// GetStringSlice gets a string value from the extensions.
func (e Extensions) GetStringSlice(key string) ([]string, bool) {
if v, ok := e[strings.ToLower(key)]; ok {
arr, isSlice := v.([]any)
@@ -82,7 +82,7 @@ type VendorExtensible struct {
Extensions Extensions
}
// AddExtension adds an extension to this extensible object
// AddExtension adds an extension to this extensible object.
func (v *VendorExtensible) AddExtension(key string, value any) {
if value == nil {
return
@@ -93,7 +93,7 @@ func (v *VendorExtensible) AddExtension(key string, value any) {
v.Extensions.Add(key, value)
}
// MarshalJSON marshals the extensions to json
// MarshalJSON marshals the extensions to json.
func (v VendorExtensible) MarshalJSON() ([]byte, error) {
toser := make(map[string]any)
for k, v := range v.Extensions {
@@ -105,7 +105,7 @@ func (v VendorExtensible) MarshalJSON() ([]byte, error) {
return json.Marshal(toser)
}
// UnmarshalJSON for this extensible object
// UnmarshalJSON for this extensible object.
func (v *VendorExtensible) UnmarshalJSON(data []byte) error {
var d map[string]any
if err := json.Unmarshal(data, &d); err != nil {
@@ -123,7 +123,7 @@ func (v *VendorExtensible) UnmarshalJSON(data []byte) error {
return nil
}
// InfoProps the properties for an info definition
// InfoProps the properties for an info definition.
type InfoProps struct {
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
@@ -142,7 +142,7 @@ type Info struct {
InfoProps
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (i Info) JSONLookup(token string) (any, error) {
if ex, ok := i.Extensions[token]; ok {
return &ex, nil
@@ -151,7 +151,7 @@ func (i Info) JSONLookup(token string) (any, error) {
return r, err
}
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (i Info) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(i.InfoProps)
if err != nil {
@@ -164,7 +164,7 @@ func (i Info) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2), nil
}
// UnmarshalJSON marshal this from JSON
// UnmarshalJSON marshal this from JSON.
func (i *Info) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &i.InfoProps); err != nil {
return err
+22 -22
View File
@@ -15,7 +15,7 @@ const (
jsonRef = "$ref"
)
// SimpleSchema describe swagger simple schemas for parameters and headers
// SimpleSchema describe swagger simple schemas for parameters and headers.
type SimpleSchema struct {
Type string `json:"type,omitempty"`
Nullable bool `json:"nullable,omitempty"`
@@ -26,7 +26,7 @@ type SimpleSchema struct {
Example any `json:"example,omitempty"`
}
// TypeName return the type (or format) of a simple schema
// TypeName return the type (or format) of a simple schema.
func (s *SimpleSchema) TypeName() string {
if s.Format != "" {
return s.Format
@@ -34,7 +34,7 @@ func (s *SimpleSchema) TypeName() string {
return s.Type
}
// ItemsTypeName yields the type of items in a simple schema array
// ItemsTypeName yields the type of items in a simple schema array.
func (s *SimpleSchema) ItemsTypeName() string {
if s.Items == nil {
return ""
@@ -53,12 +53,12 @@ type Items struct {
VendorExtensible
}
// NewItems creates a new instance of items
// NewItems creates a new instance of items.
func NewItems() *Items {
return &Items{}
}
// Typed a fluent builder method for the type of item
// Typed a fluent builder method for the type of item.
func (i *Items) Typed(tpe, format string) *Items {
i.Type = tpe
i.Format = format
@@ -71,7 +71,7 @@ func (i *Items) AsNullable() *Items {
return i
}
// CollectionOf a fluent builder method for an array item
// CollectionOf a fluent builder method for an array item.
func (i *Items) CollectionOf(items *Items, format string) *Items {
i.Type = jsonArray
i.Items = items
@@ -79,87 +79,87 @@ func (i *Items) CollectionOf(items *Items, format string) *Items {
return i
}
// WithDefault sets the default value on this item
// WithDefault sets the default value on this item.
func (i *Items) WithDefault(defaultValue any) *Items {
i.Default = defaultValue
return i
}
// WithMaxLength sets a max length value
// WithMaxLength sets a max length value.
func (i *Items) WithMaxLength(maximum int64) *Items {
i.MaxLength = &maximum
return i
}
// WithMinLength sets a min length value
// WithMinLength sets a min length value.
func (i *Items) WithMinLength(minimum int64) *Items {
i.MinLength = &minimum
return i
}
// WithPattern sets a pattern value
// WithPattern sets a pattern value.
func (i *Items) WithPattern(pattern string) *Items {
i.Pattern = pattern
return i
}
// WithMultipleOf sets a multiple of value
// WithMultipleOf sets a multiple of value.
func (i *Items) WithMultipleOf(number float64) *Items {
i.MultipleOf = &number
return i
}
// WithMaximum sets a maximum number value
// WithMaximum sets a maximum number value.
func (i *Items) WithMaximum(maximum float64, exclusive bool) *Items {
i.Maximum = &maximum
i.ExclusiveMaximum = exclusive
return i
}
// WithMinimum sets a minimum number value
// WithMinimum sets a minimum number value.
func (i *Items) WithMinimum(minimum float64, exclusive bool) *Items {
i.Minimum = &minimum
i.ExclusiveMinimum = exclusive
return i
}
// WithEnum sets a the enum values (replace)
// WithEnum sets a the enum values (replace).
func (i *Items) WithEnum(values ...any) *Items {
i.Enum = append([]any{}, values...)
return i
}
// WithMaxItems sets the max items
// WithMaxItems sets the max items.
func (i *Items) WithMaxItems(size int64) *Items {
i.MaxItems = &size
return i
}
// WithMinItems sets the min items
// WithMinItems sets the min items.
func (i *Items) WithMinItems(size int64) *Items {
i.MinItems = &size
return i
}
// UniqueValues dictates that this array can only have unique items
// UniqueValues dictates that this array can only have unique items.
func (i *Items) UniqueValues() *Items {
i.UniqueItems = true
return i
}
// AllowDuplicates this array can have duplicates
// AllowDuplicates this array can have duplicates.
func (i *Items) AllowDuplicates() *Items {
i.UniqueItems = false
return i
}
// WithValidations is a fluent method to set Items validations
// WithValidations is a fluent method to set Items validations.
func (i *Items) WithValidations(val CommonValidations) *Items {
i.SetValidations(SchemaValidations{CommonValidations: val})
return i
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (i *Items) UnmarshalJSON(data []byte) error {
var validations CommonValidations
if err := json.Unmarshal(data, &validations); err != nil {
@@ -184,7 +184,7 @@ func (i *Items) UnmarshalJSON(data []byte) error {
return nil
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (i Items) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(i.CommonValidations)
if err != nil {
@@ -205,7 +205,7 @@ func (i Items) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b4, b3, b1, b2), nil
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (i Items) JSONLookup(token string) (any, error) {
if token == jsonRef {
return &i.Ref, nil
+3 -3
View File
@@ -17,13 +17,13 @@ type License struct {
VendorExtensible
}
// LicenseProps holds the properties of a License object
// LicenseProps holds the properties of a License object.
type LicenseProps struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
}
// UnmarshalJSON hydrates License from json
// UnmarshalJSON hydrates License from json.
func (l *License) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &l.LicenseProps); err != nil {
return err
@@ -31,7 +31,7 @@ func (l *License) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &l.VendorExtensible)
}
// MarshalJSON produces License as json
// MarshalJSON produces License as json.
func (l License) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(l.LicenseProps)
if err != nil {
+1 -1
View File
@@ -138,7 +138,7 @@ func rebase(ref *Ref, v *url.URL, notEqual bool) (Ref, bool) {
return MustCreateRef(newBase.String()), true
}
// normalizeRef canonicalize a Ref, using a canonical relativeBase as its absolute anchor
// normalizeRef canonicalize a Ref, using a canonical relativeBase as its absolute anchor.
func normalizeRef(ref *Ref, relativeBase string) *Ref {
r := MustCreateRef(normalizeURI(ref.String(), relativeBase))
return &r
+21 -21
View File
@@ -13,7 +13,7 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
func init() {
func init() { //nolint:gochecknoinits // registers gob types for Operation serialization
gob.Register(map[string]any{})
gob.Register([]any{})
}
@@ -22,7 +22,7 @@ func init() {
//
// NOTES:
// - schemes, when present must be from [http, https, ws, wss]: see validate
// - Security is handled as a special case: see MarshalJSON function
// - Security is handled as a special case: see MarshalJSON function.
type OperationProps struct {
Description string `json:"description,omitempty"`
Consumes []string `json:"consumes,omitempty"`
@@ -82,7 +82,7 @@ func NewOperation(id string) *Operation {
return op
}
// SuccessResponse gets a success response model
// SuccessResponse gets a success response model.
func (o *Operation) SuccessResponse() (*Response, int, bool) {
if o.Responses == nil {
return nil, 0, false
@@ -103,7 +103,7 @@ func (o *Operation) SuccessResponse() (*Response, int, bool) {
return o.Responses.Default, 0, false
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (o Operation) JSONLookup(token string) (any, error) {
if ex, ok := o.Extensions[token]; ok {
return &ex, nil
@@ -112,7 +112,7 @@ func (o Operation) JSONLookup(token string) (any, error) {
return r, err
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (o *Operation) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &o.OperationProps); err != nil {
return err
@@ -120,7 +120,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &o.VendorExtensible)
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (o Operation) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(o.OperationProps)
if err != nil {
@@ -140,13 +140,13 @@ func (o *Operation) WithID(id string) *Operation {
return o
}
// WithDescription sets the description on this operation, allows for chaining
// WithDescription sets the description on this operation, allows for chaining.
func (o *Operation) WithDescription(description string) *Operation {
o.Description = description
return o
}
// WithSummary sets the summary on this operation, allows for chaining
// WithSummary sets the summary on this operation, allows for chaining.
func (o *Operation) WithSummary(summary string) *Operation {
o.Summary = summary
return o
@@ -170,38 +170,38 @@ func (o *Operation) WithExternalDocs(description, url string) *Operation {
return o
}
// Deprecate marks the operation as deprecated
// Deprecate marks the operation as deprecated.
func (o *Operation) Deprecate() *Operation {
o.Deprecated = true
return o
}
// Undeprecate marks the operation as not deprecated
// Undeprecate marks the operation as not deprecated.
func (o *Operation) Undeprecate() *Operation {
o.Deprecated = false
return o
}
// WithConsumes adds media types for incoming body values
// WithConsumes adds media types for incoming body values.
func (o *Operation) WithConsumes(mediaTypes ...string) *Operation {
o.Consumes = append(o.Consumes, mediaTypes...)
return o
}
// WithProduces adds media types for outgoing body values
// WithProduces adds media types for outgoing body values.
func (o *Operation) WithProduces(mediaTypes ...string) *Operation {
o.Produces = append(o.Produces, mediaTypes...)
return o
}
// WithTags adds tags for this operation
// WithTags adds tags for this operation.
func (o *Operation) WithTags(tags ...string) *Operation {
o.Tags = append(o.Tags, tags...)
return o
}
// AddParam adds a parameter to this operation, when a parameter for that location
// and with that name already exists it will be replaced
// and with that name already exists it will be replaced.
func (o *Operation) AddParam(param *Parameter) *Operation {
if param == nil {
return o
@@ -223,7 +223,7 @@ func (o *Operation) AddParam(param *Parameter) *Operation {
return o
}
// RemoveParam removes a parameter from the operation
// RemoveParam removes a parameter from the operation.
func (o *Operation) RemoveParam(name, in string) *Operation {
for i, p := range o.Parameters {
if p.Name == name && p.In == in {
@@ -241,14 +241,14 @@ func (o *Operation) SecuredWith(name string, scopes ...string) *Operation {
}
// WithDefaultResponse adds a default response to the operation.
// Passing a nil value will remove the response
// Passing a nil value will remove the response.
func (o *Operation) WithDefaultResponse(response *Response) *Operation {
return o.RespondsWith(0, response)
}
// RespondsWith adds a status code response to the operation.
// When the code is 0 the value of the response will be used as default response value.
// When the value of the response is nil it will be removed from the operation
// When the value of the response is nil it will be removed from the operation.
func (o *Operation) RespondsWith(code int, response *Response) *Operation {
if o.Responses == nil {
o.Responses = new(Responses)
@@ -279,7 +279,7 @@ type gobAlias struct {
SecurityIsEmpty bool
}
// GobEncode provides a safe gob encoder for Operation, including empty security requirements
// GobEncode provides a safe gob encoder for Operation, including empty security requirements.
func (o Operation) GobEncode() ([]byte, error) {
raw := struct {
Ext VendorExtensible
@@ -293,7 +293,7 @@ func (o Operation) GobEncode() ([]byte, error) {
return b.Bytes(), err
}
// GobDecode provides a safe gob decoder for Operation, including empty security requirements
// GobDecode provides a safe gob decoder for Operation, including empty security requirements.
func (o *Operation) GobDecode(b []byte) error {
var raw struct {
Ext VendorExtensible
@@ -310,7 +310,7 @@ func (o *Operation) GobDecode(b []byte) error {
return nil
}
// GobEncode provides a safe gob encoder for Operation, including empty security requirements
// GobEncode provides a safe gob encoder for Operation, including empty security requirements.
func (op OperationProps) GobEncode() ([]byte, error) {
raw := gobAlias{
Alias: (*opsAlias)(&op),
@@ -355,7 +355,7 @@ func (op OperationProps) GobEncode() ([]byte, error) {
return b.Bytes(), err
}
// GobDecode provides a safe gob decoder for Operation, including empty security requirements
// GobDecode provides a safe gob decoder for Operation, including empty security requirements.
func (op *OperationProps) GobDecode(b []byte) error {
var raw gobAlias
+45 -39
View File
@@ -11,45 +11,51 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// QueryParam creates a query parameter
// QueryParam creates a query parameter.
func QueryParam(name string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "query"}}
}
// HeaderParam creates a header parameter, this is always required by default
// HeaderParam creates a header parameter, this is always required by default.
func HeaderParam(name string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "header", Required: true}}
}
// PathParam creates a path parameter, this is always required
// PathParam creates a path parameter, this is always required.
func PathParam(name string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "path", Required: true}}
}
// BodyParam creates a body parameter
// BodyParam creates a body parameter.
func BodyParam(name string, schema *Schema) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "body", Schema: schema}}
}
// FormDataParam creates a body parameter
// FormDataParam creates a body parameter.
func FormDataParam(name string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"}}
}
// FileParam creates a body parameter
// FileParam creates a body parameter.
func FileParam(name string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name, In: "formData"},
SimpleSchema: SimpleSchema{Type: "file"}}
return &Parameter{
ParamProps: ParamProps{Name: name, In: "formData"},
SimpleSchema: SimpleSchema{Type: "file"},
}
}
// SimpleArrayParam creates a param for a simple array (string, int, date etc)
// SimpleArrayParam creates a param for a simple array (string, int, date etc).
func SimpleArrayParam(name, tpe, fmt string) *Parameter {
return &Parameter{ParamProps: ParamProps{Name: name},
SimpleSchema: SimpleSchema{Type: jsonArray, CollectionFormat: "csv",
Items: &Items{SimpleSchema: SimpleSchema{Type: tpe, Format: fmt}}}}
return &Parameter{
ParamProps: ParamProps{Name: name},
SimpleSchema: SimpleSchema{
Type: jsonArray, CollectionFormat: "csv",
Items: &Items{SimpleSchema: SimpleSchema{Type: tpe, Format: fmt}},
},
}
}
// ParamRef creates a parameter that's a json reference
// ParamRef creates a parameter that's a json reference.
func ParamRef(uri string) *Parameter {
p := new(Parameter)
p.Ref = MustCreateRef(uri)
@@ -60,7 +66,7 @@ func ParamRef(uri string) *Parameter {
//
// NOTE:
// - Schema is defined when "in" == "body": see validate
// - AllowEmptyValue is allowed where "in" == "query" || "formData"
// - AllowEmptyValue is allowed where "in" == "query" || "formData".
type ParamProps struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
@@ -104,7 +110,7 @@ type Parameter struct {
ParamProps
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (p Parameter) JSONLookup(token string) (any, error) {
if ex, ok := p.Extensions[token]; ok {
return &ex, nil
@@ -131,32 +137,32 @@ func (p Parameter) JSONLookup(token string) (any, error) {
return r, err
}
// WithDescription a fluent builder method for the description of the parameter
// WithDescription a fluent builder method for the description of the parameter.
func (p *Parameter) WithDescription(description string) *Parameter {
p.Description = description
return p
}
// Named a fluent builder method to override the name of the parameter
// Named a fluent builder method to override the name of the parameter.
func (p *Parameter) Named(name string) *Parameter {
p.Name = name
return p
}
// WithLocation a fluent builder method to override the location of the parameter
// WithLocation a fluent builder method to override the location of the parameter.
func (p *Parameter) WithLocation(in string) *Parameter {
p.In = in
return p
}
// Typed a fluent builder method for the type of the parameter value
// Typed a fluent builder method for the type of the parameter value.
func (p *Parameter) Typed(tpe, format string) *Parameter {
p.Type = tpe
p.Format = format
return p
}
// CollectionOf a fluent builder method for an array parameter
// CollectionOf a fluent builder method for an array parameter.
func (p *Parameter) CollectionOf(items *Items, format string) *Parameter {
p.Type = jsonArray
p.Items = items
@@ -164,32 +170,32 @@ func (p *Parameter) CollectionOf(items *Items, format string) *Parameter {
return p
}
// WithDefault sets the default value on this parameter
// WithDefault sets the default value on this parameter.
func (p *Parameter) WithDefault(defaultValue any) *Parameter {
p.AsOptional() // with default implies optional
p.Default = defaultValue
return p
}
// AllowsEmptyValues flags this parameter as being ok with empty values
// AllowsEmptyValues flags this parameter as being ok with empty values.
func (p *Parameter) AllowsEmptyValues() *Parameter {
p.AllowEmptyValue = true
return p
}
// NoEmptyValues flags this parameter as not liking empty values
// NoEmptyValues flags this parameter as not liking empty values.
func (p *Parameter) NoEmptyValues() *Parameter {
p.AllowEmptyValue = false
return p
}
// AsOptional flags this parameter as optional
// AsOptional flags this parameter as optional.
func (p *Parameter) AsOptional() *Parameter {
p.Required = false
return p
}
// AsRequired flags this parameter as required
// AsRequired flags this parameter as required.
func (p *Parameter) AsRequired() *Parameter {
if p.Default != nil { // with a default required makes no sense
return p
@@ -198,81 +204,81 @@ func (p *Parameter) AsRequired() *Parameter {
return p
}
// WithMaxLength sets a max length value
// WithMaxLength sets a max length value.
func (p *Parameter) WithMaxLength(maximum int64) *Parameter {
p.MaxLength = &maximum
return p
}
// WithMinLength sets a min length value
// WithMinLength sets a min length value.
func (p *Parameter) WithMinLength(minimum int64) *Parameter {
p.MinLength = &minimum
return p
}
// WithPattern sets a pattern value
// WithPattern sets a pattern value.
func (p *Parameter) WithPattern(pattern string) *Parameter {
p.Pattern = pattern
return p
}
// WithMultipleOf sets a multiple of value
// WithMultipleOf sets a multiple of value.
func (p *Parameter) WithMultipleOf(number float64) *Parameter {
p.MultipleOf = &number
return p
}
// WithMaximum sets a maximum number value
// WithMaximum sets a maximum number value.
func (p *Parameter) WithMaximum(maximum float64, exclusive bool) *Parameter {
p.Maximum = &maximum
p.ExclusiveMaximum = exclusive
return p
}
// WithMinimum sets a minimum number value
// WithMinimum sets a minimum number value.
func (p *Parameter) WithMinimum(minimum float64, exclusive bool) *Parameter {
p.Minimum = &minimum
p.ExclusiveMinimum = exclusive
return p
}
// WithEnum sets a the enum values (replace)
// WithEnum sets a the enum values (replace).
func (p *Parameter) WithEnum(values ...any) *Parameter {
p.Enum = append([]any{}, values...)
return p
}
// WithMaxItems sets the max items
// WithMaxItems sets the max items.
func (p *Parameter) WithMaxItems(size int64) *Parameter {
p.MaxItems = &size
return p
}
// WithMinItems sets the min items
// WithMinItems sets the min items.
func (p *Parameter) WithMinItems(size int64) *Parameter {
p.MinItems = &size
return p
}
// UniqueValues dictates that this array can only have unique items
// UniqueValues dictates that this array can only have unique items.
func (p *Parameter) UniqueValues() *Parameter {
p.UniqueItems = true
return p
}
// AllowDuplicates this array can have duplicates
// AllowDuplicates this array can have duplicates.
func (p *Parameter) AllowDuplicates() *Parameter {
p.UniqueItems = false
return p
}
// WithValidations is a fluent method to set parameter validations
// WithValidations is a fluent method to set parameter validations.
func (p *Parameter) WithValidations(val CommonValidations) *Parameter {
p.SetValidations(SchemaValidations{CommonValidations: val})
return p
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (p *Parameter) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &p.CommonValidations); err != nil {
return err
@@ -289,7 +295,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &p.ParamProps)
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (p Parameter) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(p.CommonValidations)
if err != nil {
+4 -4
View File
@@ -10,7 +10,7 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// PathItemProps the path item specific properties
// PathItemProps the path item specific properties.
type PathItemProps struct {
Get *Operation `json:"get,omitempty"`
Put *Operation `json:"put,omitempty"`
@@ -34,7 +34,7 @@ type PathItem struct {
PathItemProps
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (p PathItem) JSONLookup(token string) (any, error) {
if ex, ok := p.Extensions[token]; ok {
return &ex, nil
@@ -46,7 +46,7 @@ func (p PathItem) JSONLookup(token string) (any, error) {
return r, err
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (p *PathItem) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &p.Refable); err != nil {
return err
@@ -57,7 +57,7 @@ func (p *PathItem) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &p.PathItemProps)
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (p PathItem) MarshalJSON() ([]byte, error) {
b3, err := json.Marshal(p.Refable)
if err != nil {
+3 -3
View File
@@ -23,7 +23,7 @@ type Paths struct {
Paths map[string]PathItem `json:"-"` // custom serializer to flatten this, each entry must start with "/"
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (p Paths) JSONLookup(token string) (any, error) {
if pi, ok := p.Paths[token]; ok {
return &pi, nil
@@ -34,7 +34,7 @@ func (p Paths) JSONLookup(token string) (any, error) {
return nil, fmt.Errorf("object has no field %q: %w", token, ErrSpec)
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (p *Paths) UnmarshalJSON(data []byte) error {
var res map[string]json.RawMessage
if err := json.Unmarshal(data, &res); err != nil {
@@ -65,7 +65,7 @@ func (p *Paths) UnmarshalJSON(data []byte) error {
return nil
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (p Paths) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(p.VendorExtensible)
if err != nil {
+3 -3
View File
@@ -10,7 +10,7 @@ import (
"sort"
)
// OrderSchemaItem holds a named schema (e.g. from a property of an object)
// OrderSchemaItem holds a named schema (e.g. from a property of an object).
type OrderSchemaItem struct {
Schema
@@ -53,7 +53,7 @@ func (items OrderSchemaItems) Swap(i, j int) { items[i], items[j] = items[j], it
func (items OrderSchemaItems) Less(i, j int) (ret bool) {
ii, oki := items[i].Extensions.GetInt("x-order")
ij, okj := items[j].Extensions.GetInt("x-order")
if oki {
if oki { //nolint:nestif // nested recover logic for safe type comparison
if okj {
defer func() {
if err := recover(); err != nil {
@@ -94,7 +94,7 @@ func (items OrderSchemaItems) marshalJSONItem(item OrderSchemaItem, output *byte
// It knows how to transform its keys into an ordered slice.
type SchemaProperties map[string]Schema
// ToOrderedSchemaItems transforms the map of properties into a sortable slice
// ToOrderedSchemaItems transforms the map of properties into a sortable slice.
func (properties SchemaProperties) ToOrderedSchemaItems() OrderSchemaItems {
items := make(OrderSchemaItems, 0, len(properties))
for k, v := range properties {
+12 -12
View File
@@ -14,28 +14,28 @@ import (
"github.com/go-openapi/jsonreference"
)
// Refable is a struct for things that accept a $ref property
// Refable is a struct for things that accept a $ref property.
type Refable struct {
Ref Ref
}
// MarshalJSON marshals the ref to json
// MarshalJSON marshals the ref to json.
func (r Refable) MarshalJSON() ([]byte, error) {
return r.Ref.MarshalJSON()
}
// UnmarshalJSON unmarshals the ref from json
// UnmarshalJSON unmarshals the ref from json.
func (r *Refable) UnmarshalJSON(d []byte) error {
return json.Unmarshal(d, &r.Ref)
}
// Ref represents a json reference that is potentially resolved
// Ref represents a json reference that is potentially resolved.
type Ref struct {
jsonreference.Ref
}
// NewRef creates a new instance of a ref object
// returns an error when the reference uri is an invalid uri
// returns an error when the reference uri is an invalid uri.
func NewRef(refURI string) (Ref, error) {
ref, err := jsonreference.New(refURI)
if err != nil {
@@ -51,7 +51,7 @@ func MustCreateRef(refURI string) Ref {
return Ref{Ref: jsonreference.MustCreateRef(refURI)}
}
// RemoteURI gets the remote uri part of the ref
// RemoteURI gets the remote uri part of the ref.
func (r *Ref) RemoteURI() string {
if r.String() == "" {
return ""
@@ -62,7 +62,7 @@ func (r *Ref) RemoteURI() string {
return u.String()
}
// IsValidURI returns true when the url the ref points to can be found
// IsValidURI returns true when the url the ref points to can be found.
func (r *Ref) IsValidURI(basepaths ...string) bool {
if r.String() == "" {
return true
@@ -112,7 +112,7 @@ func (r *Ref) IsValidURI(basepaths ...string) bool {
}
// Inherits creates a new reference from a parent and a child
// If the child cannot inherit from the parent, an error is returned
// If the child cannot inherit from the parent, an error is returned.
func (r *Ref) Inherits(child Ref) (*Ref, error) {
ref, err := r.Ref.Inherits(child.Ref)
if err != nil {
@@ -121,7 +121,7 @@ func (r *Ref) Inherits(child Ref) (*Ref, error) {
return &Ref{Ref: *ref}, nil
}
// MarshalJSON marshals this ref into a JSON object
// MarshalJSON marshals this ref into a JSON object.
func (r Ref) MarshalJSON() ([]byte, error) {
str := r.String()
if str == "" {
@@ -134,7 +134,7 @@ func (r Ref) MarshalJSON() ([]byte, error) {
return json.Marshal(v)
}
// UnmarshalJSON unmarshals this ref from a JSON object
// UnmarshalJSON unmarshals this ref from a JSON object.
func (r *Ref) UnmarshalJSON(d []byte) error {
var v map[string]any
if err := json.Unmarshal(d, &v); err != nil {
@@ -143,7 +143,7 @@ func (r *Ref) UnmarshalJSON(d []byte) error {
return r.fromMap(v)
}
// GobEncode provides a safe gob encoder for Ref
// GobEncode provides a safe gob encoder for Ref.
func (r Ref) GobEncode() ([]byte, error) {
var b bytes.Buffer
raw, err := r.MarshalJSON()
@@ -154,7 +154,7 @@ func (r Ref) GobEncode() ([]byte, error) {
return b.Bytes(), err
}
// GobDecode provides a safe gob decoder for Ref
// GobDecode provides a safe gob decoder for Ref.
func (r *Ref) GobDecode(b []byte) error {
var raw []byte
buf := bytes.NewBuffer(b)
+9 -9
View File
@@ -20,7 +20,7 @@ func resolveAnyWithBase(root any, ref *Ref, result any, options *ExpandOptions)
return nil
}
// ResolveRefWithBase resolves a reference against a context root with preservation of base path
// ResolveRefWithBase resolves a reference against a context root with preservation of base path.
func ResolveRefWithBase(root any, ref *Ref, options *ExpandOptions) (*Schema, error) {
result := new(Schema)
@@ -34,7 +34,7 @@ func ResolveRefWithBase(root any, ref *Ref, options *ExpandOptions) (*Schema, er
// ResolveRef resolves a reference for a schema against a context root
// ref is guaranteed to be in root (no need to go to external files)
//
// ResolveRef is ONLY called from the code generation module
// ResolveRef is ONLY called from the code generation module.
func ResolveRef(root any, ref *Ref) (*Schema, error) {
res, _, err := ref.GetPointer().Get(root)
if err != nil {
@@ -57,7 +57,7 @@ func ResolveRef(root any, ref *Ref) (*Schema, error) {
}
}
// ResolveParameterWithBase resolves a parameter reference against a context root and base path
// ResolveParameterWithBase resolves a parameter reference against a context root and base path.
func ResolveParameterWithBase(root any, ref Ref, options *ExpandOptions) (*Parameter, error) {
result := new(Parameter)
@@ -68,12 +68,12 @@ func ResolveParameterWithBase(root any, ref Ref, options *ExpandOptions) (*Param
return result, nil
}
// ResolveParameter resolves a parameter reference against a context root
// ResolveParameter resolves a parameter reference against a context root.
func ResolveParameter(root any, ref Ref) (*Parameter, error) {
return ResolveParameterWithBase(root, ref, nil)
}
// ResolveResponseWithBase resolves response a reference against a context root and base path
// ResolveResponseWithBase resolves response a reference against a context root and base path.
func ResolveResponseWithBase(root any, ref Ref, options *ExpandOptions) (*Response, error) {
result := new(Response)
@@ -85,12 +85,12 @@ func ResolveResponseWithBase(root any, ref Ref, options *ExpandOptions) (*Respon
return result, nil
}
// ResolveResponse resolves response a reference against a context root
// ResolveResponse resolves response a reference against a context root.
func ResolveResponse(root any, ref Ref) (*Response, error) {
return ResolveResponseWithBase(root, ref, nil)
}
// ResolvePathItemWithBase resolves response a path item against a context root and base path
// ResolvePathItemWithBase resolves response a path item against a context root and base path.
func ResolvePathItemWithBase(root any, ref Ref, options *ExpandOptions) (*PathItem, error) {
result := new(PathItem)
@@ -103,7 +103,7 @@ func ResolvePathItemWithBase(root any, ref Ref, options *ExpandOptions) (*PathIt
// ResolvePathItem resolves response a path item against a context root and base path
//
// Deprecated: use ResolvePathItemWithBase instead
// Deprecated: use ResolvePathItemWithBase instead.
func ResolvePathItem(root any, ref Ref, options *ExpandOptions) (*PathItem, error) {
return ResolvePathItemWithBase(root, ref, options)
}
@@ -124,7 +124,7 @@ func ResolveItemsWithBase(root any, ref Ref, options *ExpandOptions) (*Items, er
// ResolveItems resolves parameter items reference against a context root and base path.
//
// Deprecated: use ResolveItemsWithBase instead
// Deprecated: use ResolveItemsWithBase instead.
func ResolveItems(root any, ref Ref, options *ExpandOptions) (*Items, error) {
return ResolveItemsWithBase(root, ref, options)
}
+11 -11
View File
@@ -10,7 +10,7 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// ResponseProps properties specific to a response
// ResponseProps properties specific to a response.
type ResponseProps struct {
Description string `json:"description"`
Schema *Schema `json:"schema,omitempty"`
@@ -27,19 +27,19 @@ type Response struct {
VendorExtensible
}
// NewResponse creates a new response instance
// NewResponse creates a new response instance.
func NewResponse() *Response {
return new(Response)
}
// ResponseRef creates a response as a json reference
// ResponseRef creates a response as a json reference.
func ResponseRef(url string) *Response {
resp := NewResponse()
resp.Ref = MustCreateRef(url)
return resp
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (r Response) JSONLookup(token string) (any, error) {
if ex, ok := r.Extensions[token]; ok {
return &ex, nil
@@ -51,7 +51,7 @@ func (r Response) JSONLookup(token string) (any, error) {
return ptr, err
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (r *Response) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &r.ResponseProps); err != nil {
return err
@@ -62,7 +62,7 @@ func (r *Response) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &r.VendorExtensible)
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (r Response) MarshalJSON() ([]byte, error) {
var (
b1 []byte
@@ -100,20 +100,20 @@ func (r Response) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2, b3), nil
}
// WithDescription sets the description on this response, allows for chaining
// WithDescription sets the description on this response, allows for chaining.
func (r *Response) WithDescription(description string) *Response {
r.Description = description
return r
}
// WithSchema sets the schema on this response, allows for chaining.
// Passing a nil argument removes the schema from this response
// Passing a nil argument removes the schema from this response.
func (r *Response) WithSchema(schema *Schema) *Response {
r.Schema = schema
return r
}
// AddHeader adds a header to this response
// AddHeader adds a header to this response.
func (r *Response) AddHeader(name string, header *Header) *Response {
if header == nil {
return r.RemoveHeader(name)
@@ -125,13 +125,13 @@ func (r *Response) AddHeader(name string, header *Header) *Response {
return r
}
// RemoveHeader removes a header from this response
// RemoveHeader removes a header from this response.
func (r *Response) RemoveHeader(name string) *Response {
delete(r.Headers, name)
return r
}
// AddExample adds an example to this response
// AddExample adds an example to this response.
func (r *Response) AddExample(mediaType string, example any) *Response {
if r.Examples == nil {
r.Examples = make(map[string]any)
+5 -5
View File
@@ -31,7 +31,7 @@ type Responses struct {
ResponsesProps
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (r Responses) JSONLookup(token string) (any, error) {
if token == "default" {
return r.Default, nil
@@ -47,7 +47,7 @@ func (r Responses) JSONLookup(token string) (any, error) {
return nil, fmt.Errorf("object has no field %q: %w", token, ErrSpec)
}
// UnmarshalJSON hydrates this items instance with the data from JSON
// UnmarshalJSON hydrates this items instance with the data from JSON.
func (r *Responses) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &r.ResponsesProps); err != nil {
return err
@@ -62,7 +62,7 @@ func (r *Responses) UnmarshalJSON(data []byte) error {
return nil
}
// MarshalJSON converts this items object to JSON
// MarshalJSON converts this items object to JSON.
func (r Responses) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(r.ResponsesProps)
if err != nil {
@@ -84,7 +84,7 @@ type ResponsesProps struct {
StatusCodeResponses map[int]Response
}
// MarshalJSON marshals responses as JSON
// MarshalJSON marshals responses as JSON.
func (r ResponsesProps) MarshalJSON() ([]byte, error) {
toser := map[string]Response{}
if r.Default != nil {
@@ -96,7 +96,7 @@ func (r ResponsesProps) MarshalJSON() ([]byte, error) {
return json.Marshal(toser)
}
// UnmarshalJSON unmarshals responses from JSON
// UnmarshalJSON unmarshals responses from JSON.
func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
var res map[string]json.RawMessage
if err := json.Unmarshal(data, &res); err != nil {
+75 -73
View File
@@ -13,86 +13,88 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// BooleanProperty creates a boolean property
// BooleanProperty creates a boolean property.
func BooleanProperty() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"boolean"}}}
}
// BoolProperty creates a boolean property
// BoolProperty creates a boolean property.
func BoolProperty() *Schema { return BooleanProperty() }
// StringProperty creates a string property
// StringProperty creates a string property.
func StringProperty() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}}
}
// CharProperty creates a string property
// CharProperty creates a string property.
func CharProperty() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}}}
}
// Float64Property creates a float64/double property
// Float64Property creates a float64/double property.
func Float64Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "double"}}
}
// Float32Property creates a float32/float property
// Float32Property creates a float32/float property.
func Float32Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"number"}, Format: "float"}}
}
// Int8Property creates an int8 property
// Int8Property creates an int8 property.
func Int8Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int8"}}
}
// Int16Property creates an int16 property
// Int16Property creates an int16 property.
func Int16Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int16"}}
}
// Int32Property creates an int32 property
// Int32Property creates an int32 property.
func Int32Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int32"}}
}
// Int64Property creates an int64 property
// Int64Property creates an int64 property.
func Int64Property() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"integer"}, Format: "int64"}}
}
// StrFmtProperty creates a property for the named string format
// StrFmtProperty creates a property for the named string format.
func StrFmtProperty(format string) *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: format}}
}
// DateProperty creates a date property
// DateProperty creates a date property.
func DateProperty() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date"}}
}
// DateTimeProperty creates a date time property
// DateTimeProperty creates a date time property.
func DateTimeProperty() *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"string"}, Format: "date-time"}}
}
// MapProperty creates a map property
// MapProperty creates a map property.
func MapProperty(property *Schema) *Schema {
return &Schema{SchemaProps: SchemaProps{Type: []string{"object"},
AdditionalProperties: &SchemaOrBool{Allows: true, Schema: property}}}
return &Schema{SchemaProps: SchemaProps{
Type: []string{"object"},
AdditionalProperties: &SchemaOrBool{Allows: true, Schema: property},
}}
}
// RefProperty creates a ref property
// RefProperty creates a ref property.
func RefProperty(name string) *Schema {
return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}}
}
// RefSchema creates a ref property
// RefSchema creates a ref property.
func RefSchema(name string) *Schema {
return &Schema{SchemaProps: SchemaProps{Ref: MustCreateRef(name)}}
}
// ArrayProperty creates an array property
// ArrayProperty creates an array property.
func ArrayProperty(items *Schema) *Schema {
if items == nil {
return &Schema{SchemaProps: SchemaProps{Type: []string{"array"}}}
@@ -100,17 +102,17 @@ func ArrayProperty(items *Schema) *Schema {
return &Schema{SchemaProps: SchemaProps{Items: &SchemaOrArray{Schema: items}, Type: []string{"array"}}}
}
// ComposedSchema creates a schema with allOf
// ComposedSchema creates a schema with allOf.
func ComposedSchema(schemas ...Schema) *Schema {
s := new(Schema)
s.AllOf = schemas
return s
}
// SchemaURL represents a schema url
// SchemaURL represents a schema url.
type SchemaURL string
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (r SchemaURL) MarshalJSON() ([]byte, error) {
if r == "" {
return []byte("{}"), nil
@@ -119,7 +121,7 @@ func (r SchemaURL) MarshalJSON() ([]byte, error) {
return json.Marshal(v)
}
// UnmarshalJSON unmarshal this from JSON
// UnmarshalJSON unmarshal this from JSON.
func (r *SchemaURL) UnmarshalJSON(data []byte) error {
var v map[string]any
if err := json.Unmarshal(data, &v); err != nil {
@@ -145,7 +147,7 @@ func (r *SchemaURL) fromMap(v map[string]any) error {
return nil
}
// SchemaProps describes a JSON schema (draft 4)
// SchemaProps describes a JSON schema (draft 4).
type SchemaProps struct {
ID string `json:"id,omitempty"`
Ref Ref `json:"-"`
@@ -184,7 +186,7 @@ type SchemaProps struct {
Definitions Definitions `json:"definitions,omitempty"`
}
// SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4)
// SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4).
type SwaggerSchemaProps struct {
Discriminator string `json:"discriminator,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
@@ -208,7 +210,7 @@ type Schema struct {
ExtraProps map[string]any `json:"-"`
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (s Schema) JSONLookup(token string) (any, error) {
if ex, ok := s.Extensions[token]; ok {
return &ex, nil
@@ -226,31 +228,31 @@ func (s Schema) JSONLookup(token string) (any, error) {
return r, err
}
// WithID sets the id for this schema, allows for chaining
// WithID sets the id for this schema, allows for chaining.
func (s *Schema) WithID(id string) *Schema {
s.ID = id
return s
}
// WithTitle sets the title for this schema, allows for chaining
// WithTitle sets the title for this schema, allows for chaining.
func (s *Schema) WithTitle(title string) *Schema {
s.Title = title
return s
}
// WithDescription sets the description for this schema, allows for chaining
// WithDescription sets the description for this schema, allows for chaining.
func (s *Schema) WithDescription(description string) *Schema {
s.Description = description
return s
}
// WithProperties sets the properties for this schema
// WithProperties sets the properties for this schema.
func (s *Schema) WithProperties(schemas map[string]Schema) *Schema {
s.Properties = schemas
return s
}
// SetProperty sets a property on this schema
// SetProperty sets a property on this schema.
func (s *Schema) SetProperty(name string, schema Schema) *Schema {
if s.Properties == nil {
s.Properties = make(map[string]Schema)
@@ -259,32 +261,32 @@ func (s *Schema) SetProperty(name string, schema Schema) *Schema {
return s
}
// WithAllOf sets the all of property
// WithAllOf sets the all of property.
func (s *Schema) WithAllOf(schemas ...Schema) *Schema {
s.AllOf = schemas
return s
}
// WithMaxProperties sets the max number of properties an object can have
// WithMaxProperties sets the max number of properties an object can have.
func (s *Schema) WithMaxProperties(maximum int64) *Schema {
s.MaxProperties = &maximum
return s
}
// WithMinProperties sets the min number of properties an object must have
// WithMinProperties sets the min number of properties an object must have.
func (s *Schema) WithMinProperties(minimum int64) *Schema {
s.MinProperties = &minimum
return s
}
// Typed sets the type of this schema for a single value item
// Typed sets the type of this schema for a single value item.
func (s *Schema) Typed(tpe, format string) *Schema {
s.Type = []string{tpe}
s.Format = format
return s
}
// AddType adds a type with potential format to the types for this schema
// AddType adds a type with potential format to the types for this schema.
func (s *Schema) AddType(tpe, format string) *Schema {
s.Type = append(s.Type, tpe)
if format != "" {
@@ -299,124 +301,124 @@ func (s *Schema) AsNullable() *Schema {
return s
}
// CollectionOf a fluent builder method for an array parameter
// CollectionOf a fluent builder method for an array parameter.
func (s *Schema) CollectionOf(items Schema) *Schema {
s.Type = []string{jsonArray}
s.Items = &SchemaOrArray{Schema: &items}
return s
}
// WithDefault sets the default value on this parameter
// WithDefault sets the default value on this parameter.
func (s *Schema) WithDefault(defaultValue any) *Schema {
s.Default = defaultValue
return s
}
// WithRequired flags this parameter as required
// WithRequired flags this parameter as required.
func (s *Schema) WithRequired(items ...string) *Schema {
s.Required = items
return s
}
// AddRequired adds field names to the required properties array
// AddRequired adds field names to the required properties array.
func (s *Schema) AddRequired(items ...string) *Schema {
s.Required = append(s.Required, items...)
return s
}
// WithMaxLength sets a max length value
// WithMaxLength sets a max length value.
func (s *Schema) WithMaxLength(maximum int64) *Schema {
s.MaxLength = &maximum
return s
}
// WithMinLength sets a min length value
// WithMinLength sets a min length value.
func (s *Schema) WithMinLength(minimum int64) *Schema {
s.MinLength = &minimum
return s
}
// WithPattern sets a pattern value
// WithPattern sets a pattern value.
func (s *Schema) WithPattern(pattern string) *Schema {
s.Pattern = pattern
return s
}
// WithMultipleOf sets a multiple of value
// WithMultipleOf sets a multiple of value.
func (s *Schema) WithMultipleOf(number float64) *Schema {
s.MultipleOf = &number
return s
}
// WithMaximum sets a maximum number value
// WithMaximum sets a maximum number value.
func (s *Schema) WithMaximum(maximum float64, exclusive bool) *Schema {
s.Maximum = &maximum
s.ExclusiveMaximum = exclusive
return s
}
// WithMinimum sets a minimum number value
// WithMinimum sets a minimum number value.
func (s *Schema) WithMinimum(minimum float64, exclusive bool) *Schema {
s.Minimum = &minimum
s.ExclusiveMinimum = exclusive
return s
}
// WithEnum sets a the enum values (replace)
// WithEnum sets a the enum values (replace).
func (s *Schema) WithEnum(values ...any) *Schema {
s.Enum = append([]any{}, values...)
return s
}
// WithMaxItems sets the max items
// WithMaxItems sets the max items.
func (s *Schema) WithMaxItems(size int64) *Schema {
s.MaxItems = &size
return s
}
// WithMinItems sets the min items
// WithMinItems sets the min items.
func (s *Schema) WithMinItems(size int64) *Schema {
s.MinItems = &size
return s
}
// UniqueValues dictates that this array can only have unique items
// UniqueValues dictates that this array can only have unique items.
func (s *Schema) UniqueValues() *Schema {
s.UniqueItems = true
return s
}
// AllowDuplicates this array can have duplicates
// AllowDuplicates this array can have duplicates.
func (s *Schema) AllowDuplicates() *Schema {
s.UniqueItems = false
return s
}
// AddToAllOf adds a schema to the allOf property
// AddToAllOf adds a schema to the allOf property.
func (s *Schema) AddToAllOf(schemas ...Schema) *Schema {
s.AllOf = append(s.AllOf, schemas...)
return s
}
// WithDiscriminator sets the name of the discriminator field
// WithDiscriminator sets the name of the discriminator field.
func (s *Schema) WithDiscriminator(discriminator string) *Schema {
s.Discriminator = discriminator
return s
}
// AsReadOnly flags this schema as readonly
// AsReadOnly flags this schema as readonly.
func (s *Schema) AsReadOnly() *Schema {
s.ReadOnly = true
return s
}
// AsWritable flags this schema as writeable (not read-only)
// AsWritable flags this schema as writeable (not read-only).
func (s *Schema) AsWritable() *Schema {
s.ReadOnly = false
return s
}
// WithExample sets the example for this schema
// WithExample sets the example for this schema.
func (s *Schema) WithExample(example any) *Schema {
s.Example = example
return s
@@ -440,7 +442,7 @@ func (s *Schema) WithExternalDocs(description, url string) *Schema {
return s
}
// WithXMLName sets the xml name for the object
// WithXMLName sets the xml name for the object.
func (s *Schema) WithXMLName(name string) *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -449,7 +451,7 @@ func (s *Schema) WithXMLName(name string) *Schema {
return s
}
// WithXMLNamespace sets the xml namespace for the object
// WithXMLNamespace sets the xml namespace for the object.
func (s *Schema) WithXMLNamespace(namespace string) *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -458,7 +460,7 @@ func (s *Schema) WithXMLNamespace(namespace string) *Schema {
return s
}
// WithXMLPrefix sets the xml prefix for the object
// WithXMLPrefix sets the xml prefix for the object.
func (s *Schema) WithXMLPrefix(prefix string) *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -467,7 +469,7 @@ func (s *Schema) WithXMLPrefix(prefix string) *Schema {
return s
}
// AsXMLAttribute flags this object as xml attribute
// AsXMLAttribute flags this object as xml attribute.
func (s *Schema) AsXMLAttribute() *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -476,7 +478,7 @@ func (s *Schema) AsXMLAttribute() *Schema {
return s
}
// AsXMLElement flags this object as an xml node
// AsXMLElement flags this object as an xml node.
func (s *Schema) AsXMLElement() *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -485,7 +487,7 @@ func (s *Schema) AsXMLElement() *Schema {
return s
}
// AsWrappedXML flags this object as wrapped, this is mostly useful for array types
// AsWrappedXML flags this object as wrapped, this is mostly useful for array types.
func (s *Schema) AsWrappedXML() *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -494,7 +496,7 @@ func (s *Schema) AsWrappedXML() *Schema {
return s
}
// AsUnwrappedXML flags this object as an xml node
// AsUnwrappedXML flags this object as an xml node.
func (s *Schema) AsUnwrappedXML() *Schema {
if s.XML == nil {
s.XML = new(XMLObject)
@@ -524,13 +526,13 @@ func (s *Schema) SetValidations(val SchemaValidations) {
s.PatternProperties = val.PatternProperties
}
// WithValidations is a fluent method to set schema validations
// WithValidations is a fluent method to set schema validations.
func (s *Schema) WithValidations(val SchemaValidations) *Schema {
s.SetValidations(val)
return s
}
// Validations returns a clone of the validations for this schema
// Validations returns a clone of the validations for this schema.
func (s Schema) Validations() SchemaValidations {
return SchemaValidations{
CommonValidations: CommonValidations{
@@ -553,40 +555,40 @@ func (s Schema) Validations() SchemaValidations {
}
}
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (s Schema) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(s.SchemaProps)
if err != nil {
return nil, fmt.Errorf("schema props %v: %w", err, ErrSpec)
return nil, fmt.Errorf("schema props %w: %w", err, ErrSpec)
}
b2, err := json.Marshal(s.VendorExtensible)
if err != nil {
return nil, fmt.Errorf("vendor props %v: %w", err, ErrSpec)
return nil, fmt.Errorf("vendor props %w: %w", err, ErrSpec)
}
b3, err := s.Ref.MarshalJSON()
if err != nil {
return nil, fmt.Errorf("ref prop %v: %w", err, ErrSpec)
return nil, fmt.Errorf("ref prop %w: %w", err, ErrSpec)
}
b4, err := s.Schema.MarshalJSON()
if err != nil {
return nil, fmt.Errorf("schema prop %v: %w", err, ErrSpec)
return nil, fmt.Errorf("schema prop %w: %w", err, ErrSpec)
}
b5, err := json.Marshal(s.SwaggerSchemaProps)
if err != nil {
return nil, fmt.Errorf("common validations %v: %w", err, ErrSpec)
return nil, fmt.Errorf("common validations %w: %w", err, ErrSpec)
}
var b6 []byte
if s.ExtraProps != nil {
jj, err := json.Marshal(s.ExtraProps)
if err != nil {
return nil, fmt.Errorf("extra props %v: %w", err, ErrSpec)
return nil, fmt.Errorf("extra props %w: %w", err, ErrSpec)
}
b6 = jj
}
return jsonutils.ConcatJSON(b1, b2, b3, b4, b5, b6), nil
}
// UnmarshalJSON marshal this from JSON
// UnmarshalJSON marshal this from JSON.
func (s *Schema) UnmarshalJSON(data []byte) error {
props := struct {
SchemaProps
+11 -12
View File
@@ -24,7 +24,7 @@ import (
// NOTE: if you are using the go-openapi/loads package, it will override
// this value with its own default (a loader to retrieve YAML documents as
// well as JSON ones).
var PathLoader = func(pth string) (json.RawMessage, error) {
var PathLoader = func(pth string) (json.RawMessage, error) { //nolint:gochecknoglobals // package-level default loader, overridable by go-openapi/loads
data, err := loading.LoadFromFileOrHTTP(pth)
if err != nil {
return nil, err
@@ -76,7 +76,7 @@ type schemaLoader struct {
//
// If the schema the ref is referring to holds nested refs, Resolve doesn't resolve them.
//
// If basePath is an empty string, ref is resolved against the root schema stored in the schemaLoader struct
// If basePath is an empty string, ref is resolved against the root schema stored in the schemaLoader struct.
func (r *schemaLoader) Resolve(ref *Ref, target any, basePath string) error {
return r.resolveRef(ref, target, basePath)
}
@@ -136,7 +136,7 @@ func (r *schemaLoader) resolveRef(ref *Ref, target any, basePath string) error {
root := r.root
if (ref.IsRoot() || ref.HasFragmentOnly) && root == nil && basePath != "" {
if baseRef, erb := NewRef(basePath); erb == nil {
root, _, _, _ = r.load(baseRef.GetURL())
root, _ = r.load(baseRef.GetURL())
}
}
@@ -144,7 +144,7 @@ func (r *schemaLoader) resolveRef(ref *Ref, target any, basePath string) error {
data = root
} else {
baseRef := normalizeRef(ref, basePath)
data, _, _, err = r.load(baseRef.GetURL())
data, err = r.load(baseRef.GetURL())
if err != nil {
return err
}
@@ -160,33 +160,32 @@ func (r *schemaLoader) resolveRef(ref *Ref, target any, basePath string) error {
return jsonutils.FromDynamicJSON(res, target)
}
func (r *schemaLoader) load(refURL *url.URL) (any, url.URL, bool, error) {
func (r *schemaLoader) load(refURL *url.URL) (any, error) {
debugLog("loading schema from url: %s", refURL)
toFetch := *refURL
toFetch.Fragment = ""
var err error
pth := toFetch.String()
normalized := normalizeBase(pth)
debugLog("loading doc from: %s", normalized)
data, fromCache := r.cache.Get(normalized)
if fromCache {
return data, toFetch, fromCache, nil
return data, nil
}
b, err := r.context.loadDoc(normalized)
if err != nil {
return nil, url.URL{}, false, err
return nil, err
}
var doc any
if err := json.Unmarshal(b, &doc); err != nil {
return nil, url.URL{}, false, err
return nil, err
}
r.cache.Set(normalized, doc)
return doc, toFetch, fromCache, nil
return doc, nil
}
// isCircular detects cycles in sequences of $ref.
@@ -293,8 +292,8 @@ func defaultSchemaLoader(
root any,
expandOptions *ExpandOptions,
cache ResolutionCache,
context *resolverContext) *schemaLoader {
context *resolverContext,
) *schemaLoader {
if expandOptions == nil {
expandOptions = &ExpandOptions{}
}
+11 -11
View File
@@ -20,17 +20,17 @@ const (
accessCode = "accessCode"
)
// BasicAuth creates a basic auth security scheme
// BasicAuth creates a basic auth security scheme.
func BasicAuth() *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: basic}}
}
// APIKeyAuth creates an api key auth security scheme
// APIKeyAuth creates an api key auth security scheme.
func APIKeyAuth(fieldName, valueSource string) *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{Type: apiKey, Name: fieldName, In: valueSource}}
}
// OAuth2Implicit creates an implicit flow oauth2 security scheme
// OAuth2Implicit creates an implicit flow oauth2 security scheme.
func OAuth2Implicit(authorizationURL string) *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{
Type: oauth2,
@@ -39,7 +39,7 @@ func OAuth2Implicit(authorizationURL string) *SecurityScheme {
}}
}
// OAuth2Password creates a password flow oauth2 security scheme
// OAuth2Password creates a password flow oauth2 security scheme.
func OAuth2Password(tokenURL string) *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{
Type: oauth2,
@@ -48,7 +48,7 @@ func OAuth2Password(tokenURL string) *SecurityScheme {
}}
}
// OAuth2Application creates an application flow oauth2 security scheme
// OAuth2Application creates an application flow oauth2 security scheme.
func OAuth2Application(tokenURL string) *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{
Type: oauth2,
@@ -57,7 +57,7 @@ func OAuth2Application(tokenURL string) *SecurityScheme {
}}
}
// OAuth2AccessToken creates an access token flow oauth2 security scheme
// OAuth2AccessToken creates an access token flow oauth2 security scheme.
func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme {
return &SecurityScheme{SecuritySchemeProps: SecuritySchemeProps{
Type: oauth2,
@@ -67,7 +67,7 @@ func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme {
}}
}
// SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section
// SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section.
type SecuritySchemeProps struct {
Description string `json:"description,omitempty"`
Type string `json:"type"`
@@ -79,7 +79,7 @@ type SecuritySchemeProps struct {
Scopes map[string]string `json:"scopes,omitempty"` // oauth2
}
// AddScope adds a scope to this security scheme
// AddScope adds a scope to this security scheme.
func (s *SecuritySchemeProps) AddScope(scope, description string) {
if s.Scopes == nil {
s.Scopes = make(map[string]string)
@@ -97,7 +97,7 @@ type SecurityScheme struct {
SecuritySchemeProps
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (s SecurityScheme) JSONLookup(token string) (any, error) {
if ex, ok := s.Extensions[token]; ok {
return &ex, nil
@@ -107,7 +107,7 @@ func (s SecurityScheme) JSONLookup(token string) (any, error) {
return r, err
}
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (s SecurityScheme) MarshalJSON() ([]byte, error) {
var (
b1 []byte
@@ -150,7 +150,7 @@ func (s SecurityScheme) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2), nil
}
// UnmarshalJSON marshal this from JSON
// UnmarshalJSON marshal this from JSON.
func (s *SecurityScheme) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &s.SecuritySchemeProps); err != nil {
return err
+6 -7
View File
@@ -13,13 +13,13 @@ import (
//go:generate perl -pi -e s,Json,JSON,g bindata.go
const (
// SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs
// SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs.
SwaggerSchemaURL = "http://swagger.io/v2/schema.json#"
// JSONSchemaURL the url for the json schema
// JSONSchemaURL the url for the json schema.
JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
)
// MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error
// MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error.
func MustLoadJSONSchemaDraft04() *Schema {
d, e := JSONSchemaDraft04()
if e != nil {
@@ -28,7 +28,7 @@ func MustLoadJSONSchemaDraft04() *Schema {
return d
}
// JSONSchemaDraft04 loads the json schema document for json schema draft04
// JSONSchemaDraft04 loads the json schema document for json schema draft04.
func JSONSchemaDraft04() (*Schema, error) {
b, err := jsonschemaDraft04JSONBytes()
if err != nil {
@@ -42,7 +42,7 @@ func JSONSchemaDraft04() (*Schema, error) {
return schema, nil
}
// MustLoadSwagger20Schema panics when Swagger20Schema returns an error
// MustLoadSwagger20Schema panics when Swagger20Schema returns an error.
func MustLoadSwagger20Schema() *Schema {
d, e := Swagger20Schema()
if e != nil {
@@ -51,9 +51,8 @@ func MustLoadSwagger20Schema() *Schema {
return d
}
// Swagger20Schema loads the swagger 2.0 schema from the embedded assets
// Swagger20Schema loads the swagger 2.0 schema from the embedded assets.
func Swagger20Schema() (*Schema, error) {
b, err := v2SchemaJSONBytes()
if err != nil {
return nil, err
+31 -29
View File
@@ -25,7 +25,7 @@ type Swagger struct {
SwaggerProps
}
// JSONLookup look up a value by the json property name
// JSONLookup look up a value by the json property name.
func (s Swagger) JSONLookup(token string) (any, error) {
if ex, ok := s.Extensions[token]; ok {
return &ex, nil
@@ -34,7 +34,7 @@ func (s Swagger) JSONLookup(token string) (any, error) {
return r, err
}
// MarshalJSON marshals this swagger structure to json
// MarshalJSON marshals this swagger structure to json.
func (s Swagger) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(s.SwaggerProps)
if err != nil {
@@ -47,7 +47,7 @@ func (s Swagger) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2), nil
}
// UnmarshalJSON unmarshals a swagger spec from json
// UnmarshalJSON unmarshals a swagger spec from json.
func (s *Swagger) UnmarshalJSON(data []byte) error {
var sw Swagger
if err := json.Unmarshal(data, &sw.SwaggerProps); err != nil {
@@ -60,7 +60,7 @@ func (s *Swagger) UnmarshalJSON(data []byte) error {
return nil
}
// GobEncode provides a safe gob encoder for Swagger, including extensions
// GobEncode provides a safe gob encoder for Swagger, including extensions.
func (s Swagger) GobEncode() ([]byte, error) {
var b bytes.Buffer
raw := struct {
@@ -74,7 +74,7 @@ func (s Swagger) GobEncode() ([]byte, error) {
return b.Bytes(), err
}
// GobDecode provides a safe gob decoder for Swagger, including extensions
// GobDecode provides a safe gob decoder for Swagger, including extensions.
func (s *Swagger) GobDecode(b []byte) error {
var raw struct {
Props SwaggerProps
@@ -95,7 +95,7 @@ func (s *Swagger) GobDecode(b []byte) error {
// NOTE: validation rules
// - the scheme, when present must be from [http, https, ws, wss]
// - BasePath must start with a leading "/"
// - Paths is required
// - Paths is required.
type SwaggerProps struct {
ID string `json:"id,omitempty"`
Consumes []string `json:"consumes,omitempty"`
@@ -126,7 +126,7 @@ type gobSwaggerPropsAlias struct {
SecurityIsEmpty bool
}
// GobEncode provides a safe gob encoder for SwaggerProps, including empty security requirements
// GobEncode provides a safe gob encoder for SwaggerProps, including empty security requirements.
func (o SwaggerProps) GobEncode() ([]byte, error) {
raw := gobSwaggerPropsAlias{
Alias: (*swaggerPropsAlias)(&o),
@@ -171,7 +171,7 @@ func (o SwaggerProps) GobEncode() ([]byte, error) {
return b.Bytes(), err
}
// GobDecode provides a safe gob decoder for SwaggerProps, including empty security requirements
// GobDecode provides a safe gob decoder for SwaggerProps, including empty security requirements.
func (o *SwaggerProps) GobDecode(b []byte) error {
var raw gobSwaggerPropsAlias
@@ -207,16 +207,16 @@ func (o *SwaggerProps) GobDecode(b []byte) error {
return nil
}
// Dependencies represent a dependencies property
// Dependencies represent a dependencies property.
type Dependencies map[string]SchemaOrStringArray
// SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property
// SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property.
type SchemaOrBool struct {
Allows bool
Schema *Schema
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (s SchemaOrBool) JSONLookup(token string) (any, error) {
if token == "allows" {
return s.Allows, nil
@@ -225,10 +225,12 @@ func (s SchemaOrBool) JSONLookup(token string) (any, error) {
return r, err
}
var jsTrue = []byte("true")
var jsFalse = []byte("false")
var (
jsTrue = []byte("true") //nolint:gochecknoglobals // constant-like byte slices for JSON marshaling
jsFalse = []byte("false") //nolint:gochecknoglobals // constant-like byte slices for JSON marshaling
)
// MarshalJSON convert this object to JSON
// MarshalJSON convert this object to JSON.
func (s SchemaOrBool) MarshalJSON() ([]byte, error) {
if s.Schema != nil {
return json.Marshal(s.Schema)
@@ -240,7 +242,7 @@ func (s SchemaOrBool) MarshalJSON() ([]byte, error) {
return jsTrue, nil
}
// UnmarshalJSON converts this bool or schema object from a JSON structure
// UnmarshalJSON converts this bool or schema object from a JSON structure.
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
var nw SchemaOrBool
if len(data) > 0 {
@@ -257,19 +259,19 @@ func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
return nil
}
// SchemaOrStringArray represents a schema or a string array
// SchemaOrStringArray represents a schema or a string array.
type SchemaOrStringArray struct {
Schema *Schema
Property []string
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (s SchemaOrStringArray) JSONLookup(token string) (any, error) {
r, _, err := jsonpointer.GetForToken(s.Schema, token)
return r, err
}
// MarshalJSON converts this schema object or array into JSON structure
// MarshalJSON converts this schema object or array into JSON structure.
func (s SchemaOrStringArray) MarshalJSON() ([]byte, error) {
if len(s.Property) > 0 {
return json.Marshal(s.Property)
@@ -280,7 +282,7 @@ func (s SchemaOrStringArray) MarshalJSON() ([]byte, error) {
return []byte("null"), nil
}
// UnmarshalJSON converts this schema object or array from a JSON structure
// UnmarshalJSON converts this schema object or array from a JSON structure.
func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error {
var first byte
if len(data) > 1 {
@@ -318,15 +320,15 @@ type Definitions map[string]Schema
type SecurityDefinitions map[string]*SecurityScheme
// StringOrArray represents a value that can either be a string
// or an array of strings. Mainly here for serialization purposes
// or an array of strings. Mainly here for serialization purposes.
type StringOrArray []string
// Contains returns true when the value is contained in the slice
// Contains returns true when the value is contained in the slice.
func (s StringOrArray) Contains(value string) bool {
return slices.Contains(s, value)
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (s SchemaOrArray) JSONLookup(token string) (any, error) {
if _, err := strconv.Atoi(token); err == nil {
r, _, err := jsonpointer.GetForToken(s.Schemas, token)
@@ -336,7 +338,7 @@ func (s SchemaOrArray) JSONLookup(token string) (any, error) {
return r, err
}
// UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string
// UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string.
func (s *StringOrArray) UnmarshalJSON(data []byte) error {
var first byte
if len(data) > 1 {
@@ -368,7 +370,7 @@ func (s *StringOrArray) UnmarshalJSON(data []byte) error {
}
}
// MarshalJSON converts this string or array to a JSON array or JSON string
// MarshalJSON converts this string or array to a JSON array or JSON string.
func (s StringOrArray) MarshalJSON() ([]byte, error) {
if len(s) == 1 {
return json.Marshal([]string(s)[0])
@@ -377,13 +379,13 @@ func (s StringOrArray) MarshalJSON() ([]byte, error) {
}
// SchemaOrArray represents a value that can either be a Schema
// or an array of Schema. Mainly here for serialization purposes
// or an array of Schema. Mainly here for serialization purposes.
type SchemaOrArray struct {
Schema *Schema
Schemas []Schema
}
// Len returns the number of schemas in this property
// Len returns the number of schemas in this property.
func (s SchemaOrArray) Len() int {
if s.Schema != nil {
return 1
@@ -391,7 +393,7 @@ func (s SchemaOrArray) Len() int {
return len(s.Schemas)
}
// ContainsType returns true when one of the schemas is of the specified type
// ContainsType returns true when one of the schemas is of the specified type.
func (s *SchemaOrArray) ContainsType(name string) bool {
if s.Schema != nil {
return s.Schema.Type != nil && s.Schema.Type.Contains(name)
@@ -399,7 +401,7 @@ func (s *SchemaOrArray) ContainsType(name string) bool {
return false
}
// MarshalJSON converts this schema object or array into JSON structure
// MarshalJSON converts this schema object or array into JSON structure.
func (s SchemaOrArray) MarshalJSON() ([]byte, error) {
if len(s.Schemas) > 0 {
return json.Marshal(s.Schemas)
@@ -407,7 +409,7 @@ func (s SchemaOrArray) MarshalJSON() ([]byte, error) {
return json.Marshal(s.Schema)
}
// UnmarshalJSON converts this schema object or array from a JSON structure
// UnmarshalJSON converts this schema object or array from a JSON structure.
func (s *SchemaOrArray) UnmarshalJSON(data []byte) error {
var nw SchemaOrArray
var first byte
+5 -5
View File
@@ -10,7 +10,7 @@ import (
"github.com/go-openapi/swag/jsonutils"
)
// TagProps describe a tag entry in the top level tags section of a swagger spec
// TagProps describe a tag entry in the top level tags section of a swagger spec.
type TagProps struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
@@ -27,12 +27,12 @@ type Tag struct {
TagProps
}
// NewTag creates a new tag
// NewTag creates a new tag.
func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag {
return Tag{TagProps: TagProps{Description: description, Name: name, ExternalDocs: externalDocs}}
}
// JSONLookup implements an interface to customize json pointer lookup
// JSONLookup implements an interface to customize json pointer lookup.
func (t Tag) JSONLookup(token string) (any, error) {
if ex, ok := t.Extensions[token]; ok {
return &ex, nil
@@ -42,7 +42,7 @@ func (t Tag) JSONLookup(token string) (any, error) {
return r, err
}
// MarshalJSON marshal this to JSON
// MarshalJSON marshal this to JSON.
func (t Tag) MarshalJSON() ([]byte, error) {
b1, err := json.Marshal(t.TagProps)
if err != nil {
@@ -55,7 +55,7 @@ func (t Tag) MarshalJSON() ([]byte, error) {
return jsonutils.ConcatJSON(b1, b2), nil
}
// UnmarshalJSON marshal this from JSON
// UnmarshalJSON marshal this from JSON.
func (t *Tag) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &t.TagProps); err != nil {
return err
+8 -8
View File
@@ -3,7 +3,7 @@
package spec
// CommonValidations describe common JSON-schema validations
// CommonValidations describe common JSON-schema validations.
type CommonValidations struct {
Maximum *float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
@@ -143,22 +143,22 @@ func (v CommonValidations) Validations() SchemaValidations {
}
}
// HasNumberValidations indicates if the validations are for numbers or integers
// HasNumberValidations indicates if the validations are for numbers or integers.
func (v CommonValidations) HasNumberValidations() bool {
return v.Maximum != nil || v.Minimum != nil || v.MultipleOf != nil
}
// HasStringValidations indicates if the validations are for strings
// HasStringValidations indicates if the validations are for strings.
func (v CommonValidations) HasStringValidations() bool {
return v.MaxLength != nil || v.MinLength != nil || v.Pattern != ""
}
// HasArrayValidations indicates if the validations are for arrays
// HasArrayValidations indicates if the validations are for arrays.
func (v CommonValidations) HasArrayValidations() bool {
return v.MaxItems != nil || v.MinItems != nil || v.UniqueItems
}
// HasEnum indicates if the validation includes some enum constraint
// HasEnum indicates if the validation includes some enum constraint.
func (v CommonValidations) HasEnum() bool {
return len(v.Enum) > 0
}
@@ -175,12 +175,12 @@ type SchemaValidations struct {
MinProperties *int64 `json:"minProperties,omitempty"`
}
// HasObjectValidations indicates if the validations are for objects
// HasObjectValidations indicates if the validations are for objects.
func (v SchemaValidations) HasObjectValidations() bool {
return v.MaxProperties != nil || v.MinProperties != nil || v.PatternProperties != nil
}
// SetValidations for schema validations
// SetValidations for schema validations.
func (v *SchemaValidations) SetValidations(val SchemaValidations) {
v.CommonValidations.SetValidations(val)
v.PatternProperties = val.PatternProperties
@@ -188,7 +188,7 @@ func (v *SchemaValidations) SetValidations(val SchemaValidations) {
v.MinProperties = val.MinProperties
}
// Validations for a schema
// Validations for a schema.
func (v SchemaValidations) Validations() SchemaValidations {
val := v.CommonValidations.Validations()
val.PatternProperties = v.PatternProperties
+7 -7
View File
@@ -14,43 +14,43 @@ type XMLObject struct {
Wrapped bool `json:"wrapped,omitempty"`
}
// WithName sets the xml name for the object
// WithName sets the xml name for the object.
func (x *XMLObject) WithName(name string) *XMLObject {
x.Name = name
return x
}
// WithNamespace sets the xml namespace for the object
// WithNamespace sets the xml namespace for the object.
func (x *XMLObject) WithNamespace(namespace string) *XMLObject {
x.Namespace = namespace
return x
}
// WithPrefix sets the xml prefix for the object
// WithPrefix sets the xml prefix for the object.
func (x *XMLObject) WithPrefix(prefix string) *XMLObject {
x.Prefix = prefix
return x
}
// AsAttribute flags this object as xml attribute
// AsAttribute flags this object as xml attribute.
func (x *XMLObject) AsAttribute() *XMLObject {
x.Attribute = true
return x
}
// AsElement flags this object as an xml node
// AsElement flags this object as an xml node.
func (x *XMLObject) AsElement() *XMLObject {
x.Attribute = false
return x
}
// AsWrapped flags this object as wrapped, this is mostly useful for array types
// AsWrapped flags this object as wrapped, this is mostly useful for array types.
func (x *XMLObject) AsWrapped() *XMLObject {
x.Wrapped = true
return x
}
// AsUnwrapped flags this object as an xml node
// AsUnwrapped flags this object as an xml node.
func (x *XMLObject) AsUnwrapped() *XMLObject {
x.Wrapped = false
return x
+9
View File
@@ -0,0 +1,9 @@
codecov:
notify:
after_n_builds: 2
coverage:
status:
patch:
default:
target: 80%
+6 -2
View File
@@ -1,2 +1,6 @@
secrets.yml
coverage.out
*.out
*.cov
.idea
.env
.mcp.json
.claude/
+11 -18
View File
@@ -2,25 +2,11 @@ version: "2"
linters:
default: all
disable:
- cyclop
- depguard
- errchkjson
- errorlint
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- godot
- gomoddirectives
- godox
- gosmopolitan
- inamedparam
- intrange
- ireturn
- lll
- musttag
- nestif
- exhaustruct
- nlreturn
- nonamedreturns
- noinlineerr
@@ -29,7 +15,6 @@ linters:
- testpackage
- thelper
- tparallel
- unparam
- varnamelen
- whitespace
- wrapcheck
@@ -41,8 +26,15 @@ linters:
goconst:
min-len: 2
min-occurrences: 3
cyclop:
max-complexity: 20
gocyclo:
min-complexity: 45
min-complexity: 20
exhaustive:
default-signifies-exhaustive: true
default-case-required: true
lll:
line-length: 180
exclusions:
generated: lax
presets:
@@ -58,6 +50,7 @@ formatters:
enable:
- gofmt
- goimports
- gofumpt
exclusions:
generated: lax
paths:
+4 -2
View File
@@ -23,7 +23,9 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
@@ -55,7 +57,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
reported by contacting the project team at <ivan+abuse@flanders.co.nz>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
@@ -68,7 +70,7 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
available at [<http://contributor-covenant.org/version/1/4>][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+52
View File
@@ -0,0 +1,52 @@
# Contributors
- Repository: ['go-openapi/strfmt']
| Total Contributors | Total Contributions |
| --- | --- |
| 40 | 225 |
| Username | All Time Contribution Count | All Commits |
| --- | --- | --- |
| @casualjim | 88 | <https://github.com/go-openapi/strfmt/commits?author=casualjim> |
| @fredbi | 57 | <https://github.com/go-openapi/strfmt/commits?author=fredbi> |
| @youyuanwu | 13 | <https://github.com/go-openapi/strfmt/commits?author=youyuanwu> |
| @jlambatl | 9 | <https://github.com/go-openapi/strfmt/commits?author=jlambatl> |
| @GlenDC | 5 | <https://github.com/go-openapi/strfmt/commits?author=GlenDC> |
| @padamstx | 4 | <https://github.com/go-openapi/strfmt/commits?author=padamstx> |
| @dimovnike | 3 | <https://github.com/go-openapi/strfmt/commits?author=dimovnike> |
| @carlv-stripe | 3 | <https://github.com/go-openapi/strfmt/commits?author=carlv-stripe> |
| @Copilot | 3 | <https://github.com/go-openapi/strfmt/commits?author=Copilot> |
| @keramix | 3 | <https://github.com/go-openapi/strfmt/commits?author=keramix> |
| @gregmarr | 2 | <https://github.com/go-openapi/strfmt/commits?author=gregmarr> |
| @vadorovsky | 2 | <https://github.com/go-openapi/strfmt/commits?author=vadorovsky> |
| @Ompluscator | 2 | <https://github.com/go-openapi/strfmt/commits?author=Ompluscator> |
| @johnnyg | 2 | <https://github.com/go-openapi/strfmt/commits?author=johnnyg> |
| @chakrit | 2 | <https://github.com/go-openapi/strfmt/commits?author=chakrit> |
| @bg451 | 2 | <https://github.com/go-openapi/strfmt/commits?author=bg451> |
| @aleksandr-vin | 2 | <https://github.com/go-openapi/strfmt/commits?author=aleksandr-vin> |
| @ujjwalsh | 1 | <https://github.com/go-openapi/strfmt/commits?author=ujjwalsh> |
| @kenjones-cisco | 1 | <https://github.com/go-openapi/strfmt/commits?author=kenjones-cisco> |
| @jwalter1-quest | 1 | <https://github.com/go-openapi/strfmt/commits?author=jwalter1-quest> |
| @ccoVeille | 1 | <https://github.com/go-openapi/strfmt/commits?author=ccoVeille> |
| @tylerb | 1 | <https://github.com/go-openapi/strfmt/commits?author=tylerb> |
| @tzneal | 1 | <https://github.com/go-openapi/strfmt/commits?author=tzneal> |
| @tklauser | 1 | <https://github.com/go-openapi/strfmt/commits?author=tklauser> |
| @SuperQ | 1 | <https://github.com/go-openapi/strfmt/commits?author=SuperQ> |
| @srizzling | 1 | <https://github.com/go-openapi/strfmt/commits?author=srizzling> |
| @shawnps | 1 | <https://github.com/go-openapi/strfmt/commits?author=shawnps> |
| @prashantv | 1 | <https://github.com/go-openapi/strfmt/commits?author=prashantv> |
| @krnkl | 1 | <https://github.com/go-openapi/strfmt/commits?author=krnkl> |
| @mstoykov | 1 | <https://github.com/go-openapi/strfmt/commits?author=mstoykov> |
| @maxatome | 1 | <https://github.com/go-openapi/strfmt/commits?author=maxatome> |
| @jerome-laforge | 1 | <https://github.com/go-openapi/strfmt/commits?author=jerome-laforge> |
| @justincormack | 1 | <https://github.com/go-openapi/strfmt/commits?author=justincormack> |
| @elipavlov | 1 | <https://github.com/go-openapi/strfmt/commits?author=elipavlov> |
| @gbjk | 1 | <https://github.com/go-openapi/strfmt/commits?author=gbjk> |
| @enesanbar | 1 | <https://github.com/go-openapi/strfmt/commits?author=enesanbar> |
| @CodeLingoBot | 1 | <https://github.com/go-openapi/strfmt/commits?author=CodeLingoBot> |
| @Kunde21 | 1 | <https://github.com/go-openapi/strfmt/commits?author=Kunde21> |
| @bvwells | 1 | <https://github.com/go-openapi/strfmt/commits?author=bvwells> |
| @ligustah | 1 | <https://github.com/go-openapi/strfmt/commits?author=ligustah> |
_this file was generated by the [Contributors GitHub Action](https://github.com/github-community-projects/contributors)_

Some files were not shown because too many files have changed in this diff Show More