Copy disabled (too large)
Download .txt
Showing preview only (22,326K chars total). Download the full file to get everything.
Repository: kubernetes/kube-openapi
Branch: master
Commit: ec9c827d403f
Files: 402
Total size: 21.2 MB
Directory structure:
gitextract_j6tmyxjf/
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── OWNERS
├── README.md
├── SECURITY.md
├── SECURITY_CONTACTS
├── boilerplate/
│ └── boilerplate.go.txt
├── cmd/
│ ├── openapi-gen/
│ │ ├── args/
│ │ │ └── args.go
│ │ └── openapi-gen.go
│ └── openapi2smd/
│ └── openapi2smd.go
├── code-of-conduct.md
├── go.mod
├── go.sum
├── hack/
│ ├── JSON-EXPERIMENTAL-HASH
│ ├── update-json-library.sh
│ └── verify-go-directive.sh
├── pkg/
│ ├── aggregator/
│ │ ├── aggregator.go
│ │ ├── aggregator_test.go
│ │ └── walker.go
│ ├── builder/
│ │ ├── doc.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── parameters.go
│ │ ├── parameters_test.go
│ │ └── util.go
│ ├── builder3/
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── util/
│ │ │ └── util.go
│ │ └── util.go
│ ├── cached/
│ │ ├── cache.go
│ │ └── cache_test.go
│ ├── common/
│ │ ├── common.go
│ │ ├── doc.go
│ │ ├── interfaces.go
│ │ └── restfuladapter/
│ │ ├── adapter.go
│ │ ├── param_adapter.go
│ │ ├── response_error_adapter.go
│ │ ├── route_adapter.go
│ │ └── webservice_adapter.go
│ ├── generators/
│ │ ├── README.md
│ │ ├── api_linter.go
│ │ ├── config.go
│ │ ├── config_test.go
│ │ ├── enum.go
│ │ ├── enum_test.go
│ │ ├── extension.go
│ │ ├── extension_test.go
│ │ ├── markers.go
│ │ ├── markers_test.go
│ │ ├── model_names.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── rules/
│ │ │ ├── OWNERS
│ │ │ ├── doc.go
│ │ │ ├── idl_tag.go
│ │ │ ├── idl_tag_test.go
│ │ │ ├── list_type_streaming_tags.go
│ │ │ ├── list_type_streaming_tags_test.go
│ │ │ ├── names_match.go
│ │ │ ├── names_match_test.go
│ │ │ ├── omitempty_match_case.go
│ │ │ └── omitempty_match_case_test.go
│ │ └── union.go
│ ├── handler/
│ │ ├── default_pruning.go
│ │ ├── default_pruning_test.go
│ │ ├── handler.go
│ │ └── handler_test.go
│ ├── handler3/
│ │ ├── handler.go
│ │ └── handler_test.go
│ ├── idl/
│ │ ├── doc.go
│ │ ├── listtype_test.go
│ │ ├── maptype_test.go
│ │ └── structtype_test.go
│ ├── internal/
│ │ ├── flags.go
│ │ ├── serialization.go
│ │ ├── serialization_test.go
│ │ └── third_party/
│ │ ├── go-json-experiment/
│ │ │ ├── README.md
│ │ │ └── json/
│ │ │ ├── AUTHORS
│ │ │ ├── CONTRIBUTORS
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── arshal.go
│ │ │ ├── arshal_any.go
│ │ │ ├── arshal_default.go
│ │ │ ├── arshal_funcs.go
│ │ │ ├── arshal_inlined.go
│ │ │ ├── arshal_methods.go
│ │ │ ├── arshal_test.go
│ │ │ ├── arshal_time.go
│ │ │ ├── bench_test.go
│ │ │ ├── coder_test.go
│ │ │ ├── decode.go
│ │ │ ├── decode_test.go
│ │ │ ├── diff_test.go
│ │ │ ├── doc.go
│ │ │ ├── encode.go
│ │ │ ├── encode_test.go
│ │ │ ├── errors.go
│ │ │ ├── errors_test.go
│ │ │ ├── example_orderedobject_test.go
│ │ │ ├── example_test.go
│ │ │ ├── fields.go
│ │ │ ├── fields_test.go
│ │ │ ├── fold.go
│ │ │ ├── fold_test.go
│ │ │ ├── fuzz_test.go
│ │ │ ├── inline_test.go
│ │ │ ├── intern.go
│ │ │ ├── intern_test.go
│ │ │ ├── pools.go
│ │ │ ├── state.go
│ │ │ ├── state_test.go
│ │ │ ├── testdata_test.go
│ │ │ ├── token.go
│ │ │ ├── token_test.go
│ │ │ ├── value.go
│ │ │ └── value_test.go
│ │ └── govalidator/
│ │ ├── LICENSE
│ │ ├── patterns.go
│ │ ├── validator.go
│ │ └── validator_test.go
│ ├── openapiconv/
│ │ ├── convert.go
│ │ ├── convert_test.go
│ │ └── testdata_generated_from_k8s/
│ │ ├── README.md
│ │ ├── v2_api.v1.json
│ │ ├── v2_apiextensions.k8s.io.v1.json
│ │ ├── v2_batch.v1.json
│ │ ├── v3_api.v1.json
│ │ ├── v3_apiextensions.k8s.io.v1.json
│ │ └── v3_batch.v1.json
│ ├── schemaconv/
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── proto_models.go
│ │ ├── smd.go
│ │ ├── smd_test.go
│ │ └── testdata/
│ │ ├── atomic-types.json
│ │ ├── atomic-types.yaml
│ │ ├── crds/
│ │ │ ├── openapiv2/
│ │ │ │ ├── accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json
│ │ │ │ ├── container_v1beta1_containercluster.json
│ │ │ │ ├── dataproc_v1beta1_dataprocworkflowtemplate.json
│ │ │ │ ├── dlp_v1beta1_dlpdeidentifytemplate.json
│ │ │ │ ├── monitoring_v1beta1_monitoringalertpolicy.json
│ │ │ │ ├── monitoring_v1beta1_monitoringdashboard.json
│ │ │ │ ├── privateca_v1beta1_privatecacertificate.json
│ │ │ │ ├── privateca_v1beta1_privatecacertificateauthority.json
│ │ │ │ ├── storagetransfer_v1beta1_storagetransferjob.json
│ │ │ │ └── vpcaccess_v1beta1_vpcaccessconnector.json
│ │ │ └── openapiv3/
│ │ │ ├── accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json
│ │ │ ├── container_v1beta1_containercluster.json
│ │ │ ├── dataproc_v1beta1_dataprocworkflowtemplate.json
│ │ │ ├── dlp_v1beta1_dlpdeidentifytemplate.json
│ │ │ ├── monitoring_v1beta1_monitoringalertpolicy.json
│ │ │ ├── monitoring_v1beta1_monitoringdashboard.json
│ │ │ ├── privateca_v1beta1_privatecacertificate.json
│ │ │ ├── privateca_v1beta1_privatecacertificateauthority.json
│ │ │ ├── storagetransfer_v1beta1_storagetransferjob.json
│ │ │ └── vpcaccess_v1beta1_vpcaccessconnector.json
│ │ ├── defaults.json
│ │ ├── defaults.yaml
│ │ ├── field-level-annotation.json
│ │ ├── new-schema.yaml
│ │ ├── preserve-unknown.json
│ │ ├── preserve-unknown.yaml
│ │ └── swagger.json
│ ├── schemamutation/
│ │ ├── walker.go
│ │ └── walker_test.go
│ ├── spec3/
│ │ ├── benchmark_serialization_test.go
│ │ ├── component.go
│ │ ├── component_test.go
│ │ ├── encoding.go
│ │ ├── encoding_test.go
│ │ ├── example.go
│ │ ├── example_test.go
│ │ ├── external_documentation.go
│ │ ├── external_documentation_test.go
│ │ ├── fuzz.go
│ │ ├── header.go
│ │ ├── header_test.go
│ │ ├── media_type.go
│ │ ├── media_type_test.go
│ │ ├── operation.go
│ │ ├── operation_test.go
│ │ ├── parameter.go
│ │ ├── parameter_test.go
│ │ ├── path.go
│ │ ├── path_test.go
│ │ ├── request_body.go
│ │ ├── request_body_test.go
│ │ ├── response.go
│ │ ├── response_test.go
│ │ ├── security_scheme.go
│ │ ├── security_scheme_test.go
│ │ ├── server.go
│ │ ├── server_test.go
│ │ ├── spec.go
│ │ └── testdata/
│ │ ├── appsv1spec.json
│ │ └── authorizationv1spec.json
│ ├── util/
│ │ ├── jsontesting/
│ │ │ └── json_roundtrip.go
│ │ ├── proto/
│ │ │ ├── OWNERS
│ │ │ ├── doc.go
│ │ │ ├── document.go
│ │ │ ├── document_v3.go
│ │ │ ├── openapi.go
│ │ │ ├── openapi_test.go
│ │ │ ├── testdata/
│ │ │ │ ├── openapi_v3_0_0/
│ │ │ │ │ ├── apiextensions.k8s.io/
│ │ │ │ │ │ └── v1.json
│ │ │ │ │ ├── apps/
│ │ │ │ │ │ └── v1.json
│ │ │ │ │ ├── batch/
│ │ │ │ │ │ ├── v1.json
│ │ │ │ │ │ └── v1beta1.json
│ │ │ │ │ └── v1.json
│ │ │ │ ├── swagger.json
│ │ │ │ └── swagger_next.json
│ │ │ ├── testing/
│ │ │ │ ├── openapi.go
│ │ │ │ └── openapi_v3.go
│ │ │ └── validation/
│ │ │ ├── errors.go
│ │ │ ├── types.go
│ │ │ ├── validation.go
│ │ │ └── validation_test.go
│ │ ├── sets/
│ │ │ ├── empty.go
│ │ │ └── string.go
│ │ ├── trie.go
│ │ ├── util.go
│ │ └── util_test.go
│ └── validation/
│ ├── OWNERS
│ ├── errors/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── api.go
│ │ ├── api_test.go
│ │ ├── doc.go
│ │ ├── headers.go
│ │ ├── schema.go
│ │ └── schema_test.go
│ ├── spec/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── contact_info.go
│ │ ├── contact_info_test.go
│ │ ├── external_docs.go
│ │ ├── external_docs_test.go
│ │ ├── fuzz_test.go
│ │ ├── gnostic.go
│ │ ├── gnostic_test.go
│ │ ├── header.go
│ │ ├── header_test.go
│ │ ├── info.go
│ │ ├── info_test.go
│ │ ├── items.go
│ │ ├── items_test.go
│ │ ├── license.go
│ │ ├── license_test.go
│ │ ├── operation.go
│ │ ├── operation_test.go
│ │ ├── parameter.go
│ │ ├── parameters_test.go
│ │ ├── path_item.go
│ │ ├── path_item_test.go
│ │ ├── paths.go
│ │ ├── paths_test.go
│ │ ├── ref.go
│ │ ├── ref_test.go
│ │ ├── response.go
│ │ ├── response_test.go
│ │ ├── responses.go
│ │ ├── responses_test.go
│ │ ├── schema.go
│ │ ├── schema_test.go
│ │ ├── security_scheme.go
│ │ ├── security_scheme_test.go
│ │ ├── structs_test.go
│ │ ├── swagger.go
│ │ ├── swagger_test.go
│ │ ├── tag.go
│ │ └── tag_test.go
│ ├── strfmt/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── bson/
│ │ │ └── objectid.go
│ │ ├── bson.go
│ │ ├── bson_test.go
│ │ ├── date.go
│ │ ├── date_test.go
│ │ ├── default.go
│ │ ├── default_test.go
│ │ ├── doc.go
│ │ ├── duration.go
│ │ ├── duration_test.go
│ │ ├── format.go
│ │ ├── format_test.go
│ │ ├── kubernetes-extensions.go
│ │ ├── kubernetes-extensions_test.go
│ │ ├── time.go
│ │ └── time_test.go
│ └── validate/
│ ├── .github/
│ │ └── CONTRIBUTING.md
│ ├── .gitignore
│ ├── LICENSE
│ ├── debug.go
│ ├── debug_test.go
│ ├── doc.go
│ ├── doc_test.go
│ ├── fixtures/
│ │ ├── formats/
│ │ │ └── extended-format.json
│ │ ├── jsonschema_suite/
│ │ │ ├── additionalItems.json
│ │ │ ├── additionalProperties.json
│ │ │ ├── allOf.json
│ │ │ ├── anyOf.json
│ │ │ ├── default.json
│ │ │ ├── dependencies.json
│ │ │ ├── enum.json
│ │ │ ├── format.json
│ │ │ ├── items.json
│ │ │ ├── maxItems.json
│ │ │ ├── maxLength.json
│ │ │ ├── maxProperties.json
│ │ │ ├── maximum.json
│ │ │ ├── minItems.json
│ │ │ ├── minLength.json
│ │ │ ├── minProperties.json
│ │ │ ├── minimum.json
│ │ │ ├── multipleOf.json
│ │ │ ├── not.json
│ │ │ ├── oneOf.json
│ │ │ ├── optional/
│ │ │ │ ├── bignum.json
│ │ │ │ ├── ecmascript-regex.json
│ │ │ │ ├── format.json
│ │ │ │ └── zeroTerminatedFloats.json
│ │ │ ├── pattern.json
│ │ │ ├── patternProperties.json
│ │ │ ├── properties.json
│ │ │ ├── required.json
│ │ │ ├── type.json
│ │ │ └── uniqueItems.json
│ │ └── schemas/
│ │ └── int-enum.json
│ ├── formats.go
│ ├── formats_test.go
│ ├── helpers.go
│ ├── helpers_test.go
│ ├── jsonschema_test.go
│ ├── object_validator.go
│ ├── object_validator_test.go
│ ├── options.go
│ ├── options_test.go
│ ├── result.go
│ ├── result_test.go
│ ├── rexp.go
│ ├── rexp_test.go
│ ├── schema.go
│ ├── schema_messages.go
│ ├── schema_option.go
│ ├── schema_props.go
│ ├── schema_props_test.go
│ ├── schema_test.go
│ ├── slice_validator.go
│ ├── slice_validator_test.go
│ ├── type.go
│ ├── type_test.go
│ ├── validator.go
│ ├── validator_test.go
│ ├── values.go
│ └── values_test.go
└── test/
└── integration/
├── README.md
├── builder/
│ └── main.go
├── builder3/
│ └── main.go
├── go.mod
├── go.sum
├── import.go
├── integration_suite_test.go
├── naming_test.go
├── openapiconv/
│ └── convert_test.go
├── pkg/
│ └── generated/
│ ├── namedmodels/
│ │ └── openapi_generated.go
│ └── openapi_generated.go
├── testdata/
│ ├── aggregator/
│ │ ├── openapi-0.json
│ │ ├── openapi-1.json
│ │ ├── openapi-2.json
│ │ └── openapi.json
│ ├── custom/
│ │ ├── v2.go
│ │ └── v3.go
│ ├── defaults/
│ │ └── default.go
│ ├── dummytype/
│ │ ├── alpha.go
│ │ └── beta.go
│ ├── enumtype/
│ │ └── enum.go
│ ├── golden.v2.json
│ ├── golden.v2.report
│ ├── golden.v3.json
│ ├── listtype/
│ │ ├── atomic-list.go
│ │ ├── map-list.go
│ │ ├── set-list.go
│ │ └── untyped.go
│ ├── maptype/
│ │ ├── atomic-map.go
│ │ └── granular-map.go
│ ├── namedmodels/
│ │ ├── doc.go
│ │ ├── golden.v3.json
│ │ ├── golden.v3.report
│ │ ├── struct.go
│ │ └── zz_generated_model_name.go
│ ├── structtype/
│ │ ├── atomic-struct.go
│ │ ├── field-level-override.go
│ │ └── granular-struct.go
│ ├── uniontype/
│ │ └── union.go
│ └── valuevalidation/
│ └── alpha.go
└── testutil/
└── testutil.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
# Disable gomod update
# See https://github.com/kubernetes/kube-openapi/pull/474?issuecomment-2305023746#issuecomment-2305023746
# kube-openapi directly affects the kubernetes/kubernetes API surface and we need to insulate ourselves from
# breaking the API as part of dependency bumps.
# - package-ecosystem: gomod
# directories:
# - "**/*"
# schedule:
# interval: daily
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
================================================
FILE: .github/workflows/ci.yml
================================================
name: ci-pipeline
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
ci:
strategy:
matrix:
go-version: ['1.23', '1.24', '1.25']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Build
run: |
go mod tidy && git diff --exit-code
go build ./cmd/... ./pkg/...
- name: Format
run: |
diff=$(gofmt -s -d .)
if [[ -n "${diff}" ]]; then echo "${diff}"; exit 1; fi
- name: Test
run: |
go test -race ./cmd/... ./pkg/...
- name: Run integration tests
run: |
cd test/integration
go mod tidy && git diff --exit-code
go test ./...
# We set the maximum version of the go directive here according to
# the oldest go directive that exists on our supported release branches
# in k/k.
- name: Run verify scripts
run: |
./hack/verify-go-directive.sh 1.23.0
required:
# The name of the ci jobs above change based on the golang version.
# Use this as a stable required job that depends on the above jobs.
# ref: https://github.com/kubernetes/test-infra/pull/27016
needs: ci
runs-on: ubuntu-latest
steps:
- run: echo "Required jobs success!"
================================================
FILE: .gitignore
================================================
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
# Intellij IDEA files
.idea/
*.iml
.vscode
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Thanks for taking the time to join our community and start contributing!
The [Contributor Guide](https://github.com/kubernetes/community/blob/master/contributors/guide/README.md)
provides detailed instructions on how to get your ideas and bug fixes seen and accepted.
Please remember to sign the [CNCF CLA](https://github.com/kubernetes/community/blob/master/CLA.md) and
read and observe the [Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: OWNERS
================================================
reviewers:
- sttts
- jpbetz
- jefftree
approvers:
- sttts
- jpbetz
- jefftree
emeritus_approvers:
- mbohlool
- lavalamp
- apelisse
- alexzielenski
================================================
FILE: README.md
================================================
# Kube OpenAPI
This repo is the home for Kubernetes OpenAPI discovery spec generation. The goal
is to support a subset of OpenAPI features to satisfy kubernetes use-cases but
implement that subset with little to no assumption about the structure of the
code or routes. Thus, there should be no kubernetes specific code in this repo.
There are two main parts:
- A model generator that goes through .go files, find and generate model
definitions.
- The spec generator that is responsible for dynamically generating
the final OpenAPI spec using web service routes or combining other
OpenAPI/Json specs.
## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
================================================
FILE: SECURITY.md
================================================
# Security Policy
## Security Announcements
Join the [kubernetes-security-announce] group for security and vulnerability announcements.
You can also subscribe to an RSS feed of the above using [this link][kubernetes-security-announce-rss].
## Reporting a Vulnerability
Instructions for reporting a vulnerability can be found on the
[Kubernetes Security and Disclosure Information] page.
## Supported Versions
Information about supported Kubernetes versions can be found on the
[Kubernetes version and version skew support policy] page on the Kubernetes website.
[kubernetes-security-announce]: https://groups.google.com/forum/#!forum/kubernetes-security-announce
[kubernetes-security-announce-rss]: https://groups.google.com/forum/feed/kubernetes-security-announce/msgs/rss_v2_0.xml?num=50
[Kubernetes version and version skew support policy]: https://kubernetes.io/docs/setup/release/version-skew-policy/#supported-versions
[Kubernetes Security and Disclosure Information]: https://kubernetes.io/docs/reference/issues-security/security/#report-a-vulnerability
================================================
FILE: SECURITY_CONTACTS
================================================
# Defined below are the security contacts for this repo.
#
# They are the contact point for the Product Security Committee to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/
sttts
mbohlool
================================================
FILE: boilerplate/boilerplate.go.txt
================================================
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
================================================
FILE: cmd/openapi-gen/args/args.go
================================================
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package args
import (
"fmt"
"github.com/spf13/pflag"
)
type Args struct {
OutputDir string // must be a directory path
OutputPkg string // must be a Go import-path
OutputFile string
GoHeaderFile string
// ReportFilename is added to Args for specifying name of report file used
// by API linter. If specified, API rule violations will be printed to report file.
// Otherwise default value "-" will be used which indicates stdout.
ReportFilename string
// OutputModelNameFile is the name of the file to be generated for OpenAPI schema name
// accessor functions. If empty, no model name accessor functions are generated.
// When this is specified, the OpenAPI spec generator will use the function names
// instead of Go type names for schema names.
OutputModelNameFile string
// ReadOnlyPkgs is a list of package paths that should be treated as
// read-only. Model name files will not be generated for these packages.
// This prevents the generator from attempting to write into read-only
// dependency packages (e.g. in the Go module cache).
ReadOnlyPkgs []string
}
// New returns default arguments for the generator. Returning the arguments instead
// of using default flag parsing allows registering custom arguments afterwards
func New() *Args {
args := &Args{}
// Default value for report filename is "-", which stands for stdout
args.ReportFilename = "-"
return args
}
// AddFlags add the generator flags to the flag set.
func (args *Args) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&args.OutputDir, "output-dir", "",
"the base directory under which to generate results")
fs.StringVar(&args.OutputPkg, "output-pkg", "",
"the base Go import-path under which to generate results")
fs.StringVar(&args.OutputFile, "output-file", "generated.openapi.go",
"the name of the file to be generated")
fs.StringVar(&args.OutputModelNameFile, "output-model-name-file", "",
`The filename for generated model name accessor functions.
If specified, a file with this name will be created in each package containing
a "+k8s:openapi-model-package" tag. The generated functions return fully qualified
model names, which are used in the OpenAPI spec as schema references instead of
Go type names. If empty, no model name accessor functions are generated and names
are inferred from Go type names.`)
fs.StringSliceVar(&args.ReadOnlyPkgs, "readonly-pkg", nil,
"Packages that are read-only dependencies. Model name files will not be generated "+
"for these packages. May be specified multiple times.")
fs.StringVar(&args.GoHeaderFile, "go-header-file", "",
"the path to a file containing boilerplate header text; the string \"YEAR\" will be replaced with the current 4-digit year")
fs.StringVarP(&args.ReportFilename, "report-filename", "r", args.ReportFilename,
"Name of report file used by API linter to print API violations. Default \"-\" stands for standard output. NOTE that if valid filename other than \"-\" is specified, API linter won't return error on detected API violations. This allows further check of existing API violations without stopping the OpenAPI generation toolchain.")
}
// Validate checks the given arguments.
func (args *Args) Validate() error {
if len(args.OutputDir) == 0 {
return fmt.Errorf("--output-dir must be specified")
}
if len(args.OutputPkg) == 0 {
return fmt.Errorf("--output-pkg must be specified")
}
if len(args.OutputFile) == 0 {
return fmt.Errorf("--output-file must be specified")
}
if len(args.ReportFilename) == 0 {
return fmt.Errorf("--report-filename must be specified (use \"-\" for stdout)")
}
return nil
}
================================================
FILE: cmd/openapi-gen/openapi-gen.go
================================================
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package generates openAPI definition file to be used in open API spec generation on API servers. To generate
// definition for a specific type or package add "+k8s:openapi-gen=true" tag to the type/package comment lines. To
// exclude a type from a tagged package, add "+k8s:openapi-gen=false" tag to the type comment lines.
package main
import (
"flag"
"log"
"github.com/spf13/pflag"
"k8s.io/gengo/v2"
"k8s.io/gengo/v2/generator"
"k8s.io/klog/v2"
"k8s.io/kube-openapi/cmd/openapi-gen/args"
"k8s.io/kube-openapi/pkg/generators"
)
func main() {
klog.InitFlags(nil)
args := args.New()
args.AddFlags(pflag.CommandLine)
flag.Set("logtostderr", "true")
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
if err := args.Validate(); err != nil {
log.Fatalf("Arguments validation error: %v", err)
}
boilerplate, err := gengo.GoBoilerplate(args.GoHeaderFile, gengo.StdBuildTag, gengo.StdGeneratedBy)
if err != nil {
log.Fatalf("Failed loading boilerplate: %v", err)
}
// Generates the code for model name accessors.
if len(args.OutputModelNameFile) > 0 {
modelNameTargets := func(context *generator.Context) []generator.Target {
return generators.GetModelNameTargets(context, args, boilerplate)
}
if err := gengo.Execute(
generators.NameSystems(),
generators.DefaultNameSystem(),
modelNameTargets,
gengo.StdBuildTag,
pflag.Args(),
); err != nil {
log.Fatalf("Model name code generation error: %v", err)
}
}
// Generates the code for the OpenAPIDefinitions.
openAPITargets := func(context *generator.Context) []generator.Target {
return generators.GetOpenAPITargets(context, args, boilerplate)
}
if err := gengo.Execute(
generators.NameSystems(),
generators.DefaultNameSystem(),
openAPITargets,
gengo.StdBuildTag,
pflag.Args(),
); err != nil {
log.Fatalf("OpenAPI code generation error: %v", err)
}
}
================================================
FILE: cmd/openapi2smd/openapi2smd.go
================================================
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"io"
"log"
"os"
openapi_v2 "github.com/google/gnostic-models/openapiv2"
yaml "go.yaml.in/yaml/v2"
"k8s.io/kube-openapi/pkg/schemaconv"
"k8s.io/kube-openapi/pkg/util/proto"
)
func main() {
if len(os.Args) != 1 {
log.Fatal("this program takes input on stdin and writes output to stdout.")
}
input, err := io.ReadAll(os.Stdin)
if err != nil {
log.Fatalf("error reading stdin: %v", err)
}
document, err := openapi_v2.ParseDocument(input)
if err != nil {
log.Fatalf("error interpreting stdin: %v", err)
}
models, err := proto.NewOpenAPIData(document)
if err != nil {
log.Fatalf("error interpreting models: %v", err)
}
newSchema, err := schemaconv.ToSchema(models)
if err != nil {
log.Fatalf("error converting schema format: %v", err)
}
if err := yaml.NewEncoder(os.Stdout).Encode(newSchema); err != nil {
log.Fatalf("error writing new schema: %v", err)
}
}
================================================
FILE: code-of-conduct.md
================================================
# Kubernetes Community Code of Conduct
Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md)
================================================
FILE: go.mod
================================================
module k8s.io/kube-openapi
go 1.23.0
require (
github.com/NYTimes/gziphandler v1.1.1
github.com/emicklei/go-restful/v3 v3.11.0
github.com/go-openapi/jsonreference v0.20.1
github.com/go-openapi/swag v0.23.0
github.com/google/gnostic-models v0.7.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
go.yaml.in/yaml/v2 v2.4.2
go.yaml.in/yaml/v3 v3.0.3
golang.org/x/tools v0.36.0
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated
google.golang.org/protobuf v1.35.1
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd
sigs.k8s.io/randfill v1.0.0
sigs.k8s.io/structured-merge-diff/v6 v6.2.0
sigs.k8s.io/yaml v1.4.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
golang.org/x/mod v0.27.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/tools/go/expect v0.1.0-deprecated // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
================================================
FILE: go.sum
================================================
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8=
github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
golang.org/x/tools/go/expect v0.1.0-deprecated h1:jY2C5HGYR5lqex3gEniOQL0r7Dq5+VGVgY1nudX5lXY=
golang.org/x/tools/go/expect v0.1.0-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f h1:SLb+kxmzfA87x4E4brQzB33VBbT2+x7Zq9ROIHmGn9Q=
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v6 v6.2.0 h1:msyqjP8Nyd5sF3QSmJouFSzcBIdwq4ct8d1/7VSBHIQ=
sigs.k8s.io/structured-merge-diff/v6 v6.2.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
================================================
FILE: hack/JSON-EXPERIMENTAL-HASH
================================================
540f014424240312547dcccddf11a8229ca0f463
================================================
FILE: hack/update-json-library.sh
================================================
#!/usr/bin/env bash
# This script can be called via ./hack/update-json-library.sh` to update the
# go-json-experiment fork in the repo.
# The HASH parameter may be set as part of the invocation to this script or
# the default hash from ./hack/JSON-EXPERIMENTAL-HASH will be used.
HASH="${HASH:-$(cat ./hack/JSON-EXPERIMENTAL-HASH)}"
GO_JSON_EXPERIMENT_DIR="pkg/internal/third_party/go-json-experiment/json"
rm -rf $GO_JSON_EXPERIMENT_DIR
git clone https://github.com/go-json-experiment/json $GO_JSON_EXPERIMENT_DIR
cd $GO_JSON_EXPERIMENT_DIR
git reset --hard $HASH
# If HASH was set to a keyword like HEAD, get the actual commit ID
HASH=$(git rev-parse HEAD)
cat <<EOF > ../README.md
Forked from: https://github.com/go-json-experiment/json
Commit Hash: $HASH
This internal fork exists to prevent dependency issues with go-json-experiment
until its API stabilizes.
EOF
# Remove git directories
rm -rf ".git"
rm -rf ".github"
# Remove images
rm *.png
# Remove go.{mod|sum}
# NOTE: go-json-experiment has no go mod dependencies at the moment.
# If this changes, the code will need to be updated.
rm go.mod go.sum
# Update references to point to the fork
find . -type f -name "*.go" -print0 | xargs -0 perl -pi -e "s#github.com/go-json-experiment/json#k8s.io/kube-openapi/${GO_JSON_EXPERIMENT_DIR}#g"
================================================
FILE: hack/verify-go-directive.sh
================================================
#!/usr/bin/env bash
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
function usage {
local script="$(basename $0)"
echo >&2 "Usage: ${script} <maximum go directive>
This script should be run at the root of a module.
Compare the go directive in the local working copy's go.mod
to the specified maximum version it can be. Versions provided
here are of the form 1.x.y, without the 'go' prefix.
Examples:
${script} 1.20
${script} 1.21.6
"
exit 1
}
max="$1"
# If max is empty, print usage and error
if [[ -z "${max}" ]]; then
usage;
fi
# Don't specify the version with the go prefix, just 1.x.y will do.
if [[ ! "${max}" =~ ^[0-9]\.[0-9]+(\.[0-9]+)?$ ]]; then
usage
fi
current=$(awk '/^go / {print $2;}' go.mod)
if [[ -z "${current}" ]]; then
echo >&2 "FAIL: could not get value of go directive from go.mod"
exit 1
fi
if ! printf '%s\n' "${current}" "${max}" | sort --check=silent --version-sort; then
echo >&2 "FAIL: current Go directive ${current} is greater than ${max}"
exit 1
fi
================================================
FILE: pkg/aggregator/aggregator.go
================================================
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package aggregator
import (
"fmt"
"reflect"
"sort"
"strings"
"k8s.io/kube-openapi/pkg/schemamutation"
"k8s.io/kube-openapi/pkg/util"
"k8s.io/kube-openapi/pkg/validation/spec"
)
const gvkKey = "x-kubernetes-group-version-kind"
// usedDefinitionForSpec returns a map with all used definitions in the provided spec as keys and true as values.
func usedDefinitionForSpec(root *spec.Swagger) map[string]bool {
usedDefinitions := map[string]bool{}
walkOnAllReferences(func(ref *spec.Ref) {
if refStr := ref.String(); refStr != "" && strings.HasPrefix(refStr, definitionPrefix) {
usedDefinitions[refStr[len(definitionPrefix):]] = true
}
}, root)
return usedDefinitions
}
// FilterSpecByPaths removes unnecessary paths and definitions used by those paths.
// i.e. if a Path removed by this function, all definitions used by it and not used
// anywhere else will also be removed.
func FilterSpecByPaths(sp *spec.Swagger, keepPathPrefixes []string) {
*sp = *FilterSpecByPathsWithoutSideEffects(sp, keepPathPrefixes)
}
// FilterSpecByPathsWithoutSideEffects removes unnecessary paths and definitions used by those paths.
// i.e. if a Path removed by this function, all definitions used by it and not used
// anywhere else will also be removed.
// It does not modify the input, but the output shares data structures with the input.
func FilterSpecByPathsWithoutSideEffects(sp *spec.Swagger, keepPathPrefixes []string) *spec.Swagger {
if sp.Paths == nil {
return sp
}
// Walk all references to find all used definitions. This function
// want to only deal with unused definitions resulted from filtering paths.
// Thus a definition will be removed only if it has been used before but
// it is unused because of a path prune.
initialUsedDefinitions := usedDefinitionForSpec(sp)
// First remove unwanted paths
prefixes := util.NewTrie(keepPathPrefixes)
ret := *sp
ret.Paths = &spec.Paths{
VendorExtensible: sp.Paths.VendorExtensible,
Paths: map[string]spec.PathItem{},
}
for path, pathItem := range sp.Paths.Paths {
if !prefixes.HasPrefix(path) {
continue
}
ret.Paths.Paths[path] = pathItem
}
// Walk all references to find all definition references.
usedDefinitions := usedDefinitionForSpec(&ret)
// Remove unused definitions
ret.Definitions = spec.Definitions{}
for k, v := range sp.Definitions {
if usedDefinitions[k] || !initialUsedDefinitions[k] {
ret.Definitions[k] = v
}
}
return &ret
}
// renameDefinitions renames definition references, without mutating the input.
// The output might share data structures with the input.
func renameDefinitions(s *spec.Swagger, renames map[string]string) *spec.Swagger {
refRenames := make(map[string]string, len(renames))
foundOne := false
for k, v := range renames {
refRenames[definitionPrefix+k] = definitionPrefix + v
if _, ok := s.Definitions[k]; ok {
foundOne = true
}
}
if !foundOne {
return s
}
ret := &spec.Swagger{}
*ret = *s
ret = schemamutation.ReplaceReferences(func(ref *spec.Ref) *spec.Ref {
refName := ref.String()
if newRef, found := refRenames[refName]; found {
ret := spec.MustCreateRef(newRef)
return &ret
}
return ref
}, ret)
renamedDefinitions := make(spec.Definitions, len(ret.Definitions))
for k, v := range ret.Definitions {
if newRef, found := renames[k]; found {
k = newRef
}
renamedDefinitions[k] = v
}
ret.Definitions = renamedDefinitions
return ret
}
// renameParameters renames parameter references, without mutating the input.
// The output might share data structures with the input.
func renameParameters(s *spec.Swagger, renames map[string]string) *spec.Swagger {
refRenames := make(map[string]string, len(renames))
foundOne := false
for k, v := range renames {
refRenames[parameterPrefix+k] = parameterPrefix + v
if _, ok := s.Parameters[k]; ok {
foundOne = true
}
}
if !foundOne {
return s
}
ret := &spec.Swagger{}
*ret = *s
ret = schemamutation.ReplaceReferences(func(ref *spec.Ref) *spec.Ref {
refName := ref.String()
if newRef, found := refRenames[refName]; found {
ret := spec.MustCreateRef(newRef)
return &ret
}
return ref
}, ret)
renamed := make(map[string]spec.Parameter, len(ret.Parameters))
for k, v := range ret.Parameters {
if newRef, found := renames[k]; found {
k = newRef
}
renamed[k] = v
}
ret.Parameters = renamed
return ret
}
// MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters is the same as
// MergeSpecs except it will ignore any path conflicts by keeping the paths of
// destination. It will rename definition and parameter conflicts.
func MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters(dest, source *spec.Swagger) error {
return mergeSpecs(dest, source, true, true, true)
}
// MergeSpecsIgnorePathConflictDeprecated is the same as MergeSpecs except it will ignore any path
// conflicts by keeping the paths of destination. It will rename definition and
// parameter conflicts.
func MergeSpecsIgnorePathConflictDeprecated(dest, source *spec.Swagger) error {
return mergeSpecs(dest, source, true, false, true)
}
// MergeSpecsFailOnDefinitionConflict is different from MergeSpecs as it fails if there is
// a definition or parameter conflict.
func MergeSpecsFailOnDefinitionConflict(dest, source *spec.Swagger) error {
return mergeSpecs(dest, source, false, false, false)
}
// MergeSpecs copies paths, definitions and parameters from source to dest, rename
// definitions if needed. It will fail on path conflicts.
//
// The destination is mutated, the source is not.
func MergeSpecs(dest, source *spec.Swagger) error {
return mergeSpecs(dest, source, true, true, false)
}
// mergeSpecs merges source into dest while resolving conflicts.
// The source is not mutated.
func mergeSpecs(dest, source *spec.Swagger, renameModelConflicts, renameParameterConflicts, ignorePathConflicts bool) (err error) {
// Paths may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering).
if source.Paths == nil {
// When a source spec does not have any path, that means none of the definitions
// are used thus we should not do anything
return nil
}
if dest.Paths == nil {
dest.Paths = &spec.Paths{}
}
if ignorePathConflicts {
keepPaths := []string{}
hasConflictingPath := false
for k := range source.Paths.Paths {
if _, found := dest.Paths.Paths[k]; !found {
keepPaths = append(keepPaths, k)
} else {
hasConflictingPath = true
}
}
if len(keepPaths) == 0 {
// There is nothing to merge. All paths are conflicting.
return nil
}
if hasConflictingPath {
source = FilterSpecByPathsWithoutSideEffects(source, keepPaths)
}
}
// Check for model conflicts and rename to make definitions conflict-free (modulo different GVKs)
usedNames := map[string]bool{}
for k := range dest.Definitions {
usedNames[k] = true
}
renames := map[string]string{}
DEFINITIONLOOP:
for k, v := range source.Definitions {
existing, found := dest.Definitions[k]
if !found || deepEqualDefinitionsModuloGVKs(&existing, &v) {
// skip for now, we copy them after the rename loop
continue
}
if !renameModelConflicts {
return fmt.Errorf("model name conflict in merging OpenAPI spec: %s", k)
}
// Reuse previously renamed model if one exists
var newName string
i := 1
for found {
i++
newName = fmt.Sprintf("%s_v%d", k, i)
existing, found = dest.Definitions[newName]
if found && deepEqualDefinitionsModuloGVKs(&existing, &v) {
renames[k] = newName
continue DEFINITIONLOOP
}
}
_, foundInSource := source.Definitions[newName]
for usedNames[newName] || foundInSource {
i++
newName = fmt.Sprintf("%s_v%d", k, i)
_, foundInSource = source.Definitions[newName]
}
renames[k] = newName
usedNames[newName] = true
}
source = renameDefinitions(source, renames)
// Check for parameter conflicts and rename to make parameters conflict-free
usedNames = map[string]bool{}
for k := range dest.Parameters {
usedNames[k] = true
}
renames = map[string]string{}
PARAMETERLOOP:
for k, p := range source.Parameters {
existing, found := dest.Parameters[k]
if !found || reflect.DeepEqual(&existing, &p) {
// skip for now, we copy them after the rename loop
continue
}
if !renameParameterConflicts {
return fmt.Errorf("parameter name conflict in merging OpenAPI spec: %s", k)
}
// Reuse previously renamed parameter if one exists
var newName string
i := 1
for found {
i++
newName = fmt.Sprintf("%s_v%d", k, i)
existing, found = dest.Parameters[newName]
if found && reflect.DeepEqual(&existing, &p) {
renames[k] = newName
continue PARAMETERLOOP
}
}
_, foundInSource := source.Parameters[newName]
for usedNames[newName] || foundInSource {
i++
newName = fmt.Sprintf("%s_v%d", k, i)
_, foundInSource = source.Parameters[newName]
}
renames[k] = newName
usedNames[newName] = true
}
source = renameParameters(source, renames)
// Now without conflict (modulo different GVKs), copy definitions to dest
for k, v := range source.Definitions {
if existing, found := dest.Definitions[k]; !found {
if dest.Definitions == nil {
dest.Definitions = make(spec.Definitions, len(source.Definitions))
}
dest.Definitions[k] = v
} else if merged, changed, err := mergedGVKs(&existing, &v); err != nil {
return err
} else if changed {
existing.Extensions[gvkKey] = merged
}
}
// Now without conflict, copy parameters to dest
for k, v := range source.Parameters {
if _, found := dest.Parameters[k]; !found {
if dest.Parameters == nil {
dest.Parameters = make(map[string]spec.Parameter, len(source.Parameters))
}
dest.Parameters[k] = v
}
}
// Check for path conflicts
for k, v := range source.Paths.Paths {
if _, found := dest.Paths.Paths[k]; found {
return fmt.Errorf("unable to merge: duplicated path %s", k)
}
// PathItem may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering).
if dest.Paths.Paths == nil {
dest.Paths.Paths = map[string]spec.PathItem{}
}
dest.Paths.Paths[k] = v
}
return nil
}
// deepEqualDefinitionsModuloGVKs compares s1 and s2, but ignores the x-kubernetes-group-version-kind extension.
func deepEqualDefinitionsModuloGVKs(s1, s2 *spec.Schema) bool {
if s1 == nil {
return s2 == nil
} else if s2 == nil {
return false
}
if !reflect.DeepEqual(s1.Extensions, s2.Extensions) {
for k, v := range s1.Extensions {
if k == gvkKey {
continue
}
if !reflect.DeepEqual(v, s2.Extensions[k]) {
return false
}
}
len1 := len(s1.Extensions)
len2 := len(s2.Extensions)
if _, found := s1.Extensions[gvkKey]; found {
len1--
}
if _, found := s2.Extensions[gvkKey]; found {
len2--
}
if len1 != len2 {
return false
}
if s1.Extensions != nil {
shallowCopy := *s1
s1 = &shallowCopy
s1.Extensions = nil
}
if s2.Extensions != nil {
shallowCopy := *s2
s2 = &shallowCopy
s2.Extensions = nil
}
}
return reflect.DeepEqual(s1, s2)
}
// mergedGVKs merges the x-kubernetes-group-version-kind slices and returns the result, and whether
// s1's x-kubernetes-group-version-kind slice was changed at all.
func mergedGVKs(s1, s2 *spec.Schema) (interface{}, bool, error) {
gvk1, found1 := s1.Extensions[gvkKey]
gvk2, found2 := s2.Extensions[gvkKey]
if !found1 {
return gvk2, found2, nil
}
if !found2 {
return gvk1, false, nil
}
slice1, ok := gvk1.([]interface{})
if !ok {
return nil, false, fmt.Errorf("expected slice of GroupVersionKinds, got: %+v", slice1)
}
slice2, ok := gvk2.([]interface{})
if !ok {
return nil, false, fmt.Errorf("expected slice of GroupVersionKinds, got: %+v", slice2)
}
ret := make([]interface{}, len(slice1), len(slice1)+len(slice2))
keys := make([]string, 0, len(slice1)+len(slice2))
copy(ret, slice1)
seen := make(map[string]bool, len(slice1))
for _, x := range slice1 {
gvk, ok := x.(map[string]interface{})
if !ok {
return nil, false, fmt.Errorf(`expected {"group": <group>, "kind": <kind>, "version": <version>}, got: %#v`, x)
}
k := fmt.Sprintf("%s/%s.%s", gvk["group"], gvk["version"], gvk["kind"])
keys = append(keys, k)
seen[k] = true
}
changed := false
for _, x := range slice2 {
gvk, ok := x.(map[string]interface{})
if !ok {
return nil, false, fmt.Errorf(`expected {"group": <group>, "kind": <kind>, "version": <version>}, got: %#v`, x)
}
k := fmt.Sprintf("%s/%s.%s", gvk["group"], gvk["version"], gvk["kind"])
if seen[k] {
continue
}
ret = append(ret, x)
keys = append(keys, k)
changed = true
}
if changed {
sort.Sort(byKeys{ret, keys})
}
return ret, changed, nil
}
type byKeys struct {
values []interface{}
keys []string
}
func (b byKeys) Len() int {
return len(b.values)
}
func (b byKeys) Less(i, j int) bool {
return b.keys[i] < b.keys[j]
}
func (b byKeys) Swap(i, j int) {
b.values[i], b.values[j] = b.values[j], b.values[i]
b.keys[i], b.keys[j] = b.keys[j], b.keys[i]
}
================================================
FILE: pkg/aggregator/aggregator_test.go
================================================
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package aggregator
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/kube-openapi/pkg/handler"
"k8s.io/kube-openapi/pkg/validation/spec"
"sigs.k8s.io/yaml"
)
type DebugSpec struct {
*spec.Swagger
}
func (d DebugSpec) String() string {
bytes, err := d.Swagger.MarshalJSON()
if err != nil {
return fmt.Sprintf("DebugSpec.String failed: %s", err)
}
return string(bytes)
}
func TestFilterSpecs(t *testing.T) {
var spec1, spec1_filtered *spec.Swagger
ast := assert.New(t)
err := yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
delete:
summary: "Test API Delete"
operationId: "deleteTest"
parameters:
- $ref: "#/parameters/body-deleteoptions"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
delete:
summary: "Test2 API Delete"
operationId: "deleteTest2"
parameters:
- schema:
$ref: "#/definitions/DeleteOptions"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
DeleteOptions:
type: "object"
properties:
preconditions:
$ref: "#/definitions/Preconditions"
Preconditions:
type: "string"
parameters:
body-deleteoptions:
name: body
in: body
schema:
$ref: "#/definitions/DeleteOptions"
`), &spec1)
ast.NoError(err)
err = yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
delete:
summary: "Test API Delete"
operationId: "deleteTest"
parameters:
- $ref: "#/parameters/body-deleteoptions"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
DeleteOptions:
type: "object"
properties:
preconditions:
$ref: "#/definitions/Preconditions"
Preconditions:
type: "string"
parameters:
body-deleteoptions:
name: body
in: body
schema:
$ref: "#/definitions/DeleteOptions"
`), &spec1_filtered)
ast.NoError(err)
orig_spec1, _ := cloneSpec(spec1)
new_spec1 := FilterSpecByPathsWithoutSideEffects(spec1, []string{"/test"})
ast.Equal(DebugSpec{spec1_filtered}, DebugSpec{new_spec1})
ast.Equal(DebugSpec{orig_spec1}, DebugSpec{spec1}, "unexpected mutation of input")
}
func TestFilterSpecsWithUnusedDefinitions(t *testing.T) {
var spec1, spec1Filtered *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
Unused:
type: "object"
`), &spec1)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
Unused:
type: "object"
`), &spec1Filtered)
ast := assert.New(t)
orig_spec1, _ := cloneSpec(spec1)
new_spec1 := FilterSpecByPathsWithoutSideEffects(spec1, []string{"/test"})
ast.Equal(DebugSpec{spec1Filtered}, DebugSpec{new_spec1})
ast.Equal(DebugSpec{orig_spec1}, DebugSpec{spec1}, "unexpected mutation of input")
}
func TestMergeSpecsSimple(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
- $ref: "#/parameters/b"
definitions:
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
parameters:
b:
in: query
name: b
schema:
$ref: "#/definitions/Test2"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
- $ref: "#/parameters/b"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
b:
in: query
name: b
schema:
$ref: "#/definitions/Test2"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}.String(), DebugSpec{spec1}.String())
ast.Equal(DebugSpec{orig_spec2}.String(), DebugSpec{spec2}.String(), "unexpected mutation of input")
}
func TestMergeSpecsEmptyDefinitions(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
responses:
405:
description: "Invalid input"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
definitions:
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
responses:
405:
description: "Invalid input"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
definitions:
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsEmptyPaths(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
`), &spec1)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
definitions:
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
`), &spec2)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test2"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
Test2:
type: "object"
properties:
other:
$ref: "#/definitions/Other"
Other:
type: "string"
`), &expected)
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsReuseModel(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsRenameModel(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
definitions:
Test:
description: "This Test has a description"
type: "object"
properties:
id:
type: "integer"
format: "int64"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
tags:
- "test"
summary: "Test API"
operationId: "addTest"
parameters:
- in: "body"
name: "body"
description: "test object"
required: true
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
responses:
405:
description: "Invalid input"
$ref: "#/definitions/InvalidInput"
/othertest:
post:
tags:
- "test2"
summary: "Test2 API"
operationId: "addTest2"
consumes:
- "application/json"
produces:
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "test2 object"
required: true
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
definitions:
Test:
type: "object"
properties:
id:
type: "integer"
format: "int64"
status:
type: "string"
description: "Status"
Test_v2:
description: "This Test has a description"
type: "object"
properties:
id:
type: "integer"
format: "int64"
InvalidInput:
type: "string"
format: "string"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1}, DebugSpec{spec1}.String())
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsRenameModelWithExistingV2InDestination(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/testv2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
definitions:
Test:
type: "object"
Test_v2:
description: "This is an existing Test_v2 in destination schema"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
definitions:
Test:
description: "This Test has a description"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/testv2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v3"
- $ref: "#/parameters/a_v3"
definitions:
Test:
type: "object"
Test_v2:
description: "This is an existing Test_v2 in destination schema"
type: "object"
Test_v3:
description: "This Test has a description"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
a_v3:
in: query
name: a
schema:
$ref: "#/definitions/Test_v3"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsMultipleRenamesOfModelsAndLateConflict(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/test3:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v3"
- $ref: "#/parameters/a_v3"
definitions:
Test:
description: "I used to be Test in destination"
type: "object"
Test_v3:
description: "I used to be Test_v3 in destination"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v3:
in: query
name: a
schema:
$ref: "#/definitions/Test_v3"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/othertest2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
definitions:
Test:
description: "I used to be Test in source"
type: "object"
Test_v2:
description: "I used to be Test_v2 in source"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/test3:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v3"
- $ref: "#/parameters/a_v3"
/othertest2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v4"
- $ref: "#/parameters/a_v4"
definitions:
Test:
description: "I used to be Test in destination"
type: "object"
Test_v2:
description: "I used to be Test_v2 in source"
type: "object"
Test_v3:
description: "I used to be Test_v3 in destination"
type: "object"
Test_v4:
description: "I used to be Test in source"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
a_v3:
in: query
name: a
schema:
$ref: "#/definitions/Test_v3"
a_v4:
in: query
name: a
schema:
$ref: "#/definitions/Test_v4"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func TestMergeSpecsRenameModelWithExistingV2InSource(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
definitions:
Test:
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
`), &spec1))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/testv2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
definitions:
Test:
description: "This Test has a description"
type: "object"
Test_v2:
description: "This is an existing Test_v2 in source schema"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
`), &spec2))
require.NoError(t, yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
- $ref: "#/parameters/a"
/testv2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
- $ref: "#/parameters/a_v2"
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v3"
- $ref: "#/parameters/a_v3"
definitions:
Test:
type: "object"
Test_v2:
description: "This is an existing Test_v2 in source schema"
type: "object"
Test_v3:
description: "This Test has a description"
type: "object"
parameters:
a:
in: query
name: a
schema:
$ref: "#/definitions/Test"
a_v2:
in: query
name: a
schema:
$ref: "#/definitions/Test_v2"
a_v3:
in: query
name: a
schema:
$ref: "#/definitions/Test_v3"
`), &expected))
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
// This tests if there are three specs, where the first two use the same object definition,
// while the third one uses its own.
// We expect the merged schema to contain two versions of the object, not three
func TestTwoMergeSpecsFirstTwoSchemasHaveSameDefinition(t *testing.T) {
var spec1, spec2, spec3, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
description: "spec1 and spec2 use the same object definition, while spec3 doesn't"
type: "object"
`), &spec1)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
description: "spec1 and spec2 use the same object definition, while spec3 doesn't"
type: "object"
`), &spec2)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test3:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
description: "spec3 has its own definition (the description doesn't match)"
type: "object"
`), &spec3)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
/test2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
/test3:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
definitions:
Test:
description: "spec1 and spec2 use the same object definition, while spec3 doesn't"
type: "object"
Test_v2:
description: "spec3 has its own definition (the description doesn't match)"
type: "object"
`), &expected)
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
orig_spec3, _ := cloneSpec(spec3)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
if !ast.NoError(MergeSpecs(spec1, spec3)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of spec2 input")
ast.Equal(DebugSpec{orig_spec3}, DebugSpec{spec3}, "unexpected mutation of spec3 input")
}
// This tests if there are three specs, where the last two use the same object definition,
// while the first one uses its own.
// We expect the merged schema to contain two versions of the object, not three
func TestTwoMergeSpecsLastTwoSchemasHaveSameDefinition(t *testing.T) {
var spec1, spec2, spec3, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
type: "object"
`), &spec1)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
description: "spec2 and spec3 use the same object definition, while spec1 doesn't"
type: "object"
`), &spec2)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/othertest2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
description: "spec2 and spec3 use the same object definition, while spec1 doesn't"
type: "object"
`), &spec3)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
/othertest:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
/othertest2:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test_v2"
definitions:
Test:
type: "object"
Test_v2:
description: "spec2 and spec3 use the same object definition, while spec1 doesn't"
type: "object"
`), &expected)
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
orig_spec3, _ := cloneSpec(spec3)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
if !ast.NoError(MergeSpecs(spec1, spec3)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of spec2 input")
ast.Equal(DebugSpec{orig_spec3}, DebugSpec{spec3}, "unexpected mutation of spec3 input")
}
func TestSafeMergeSpecsSimple(t *testing.T) {
var fooSpec, barSpec, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &fooSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/bar:
post:
summary: "Bar API"
operationId: "barTest"
parameters:
- in: "body"
name: "body"
description: "bar object"
required: true
schema:
$ref: "#/definitions/Bar"
responses:
200:
description: "OK"
definitions:
Bar:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &barSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
/bar:
post:
summary: "Bar API"
operationId: "barTest"
parameters:
- in: "body"
name: "body"
description: "bar object"
required: true
schema:
$ref: "#/definitions/Bar"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
Bar:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &expected)
ast := assert.New(t)
orig_barSpec, err := cloneSpec(barSpec)
if !ast.NoError(err) {
return
}
if !ast.NoError(MergeSpecsFailOnDefinitionConflict(fooSpec, barSpec)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{fooSpec})
ast.Equal(DebugSpec{orig_barSpec}, DebugSpec{barSpec}, "unexpected mutation of input")
}
func TestSafeMergeSpecsReuseModel(t *testing.T) {
var fooSpec, barSpec, expected *spec.Swagger
if err := yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
x-kubernetes-group-version-kind:
- group: group1
version: v1
kind: Foo
- group: group3
version: v1
kind: Foo
`), &fooSpec); err != nil {
t.Fatal(err)
}
if err := yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/refoo:
post:
summary: "Refoo API"
operationId: "refooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
x-kubernetes-group-version-kind:
- group: group2
version: v1
kind: Foo
`), &barSpec); err != nil {
t.Fatal(err)
}
if err := yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
/refoo:
post:
summary: "Refoo API"
operationId: "refooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
x-kubernetes-group-version-kind:
- group: group1
version: v1
kind: Foo
- group: group2
version: v1
kind: Foo
- group: group3
version: v1
kind: Foo
`), &expected); err != nil {
t.Fatal(err)
}
ast := assert.New(t)
orig_barSpec, err := cloneSpec(barSpec)
if !ast.NoError(err) {
return
}
if !ast.NoError(MergeSpecsFailOnDefinitionConflict(fooSpec, barSpec)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{fooSpec})
ast.Equal(DebugSpec{orig_barSpec}, DebugSpec{barSpec}, "unexpected mutation of input")
}
func TestSafeMergeSpecsReuseModelFails(t *testing.T) {
var fooSpec, barSpec, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &fooSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/refoo:
post:
summary: "Refoo API"
operationId: "refooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
new_field:
type: "string"
`), &barSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
/refoo:
post:
summary: "Refoo API"
operationId: "refooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &expected)
ast := assert.New(t)
ast.Error(MergeSpecsFailOnDefinitionConflict(fooSpec, barSpec))
}
func TestMergeSpecsIgnorePathConflicts(t *testing.T) {
var fooSpec, barSpec, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &fooSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Should be ignored"
/bar:
post:
summary: "Bar API"
operationId: "barTest"
parameters:
- in: "body"
name: "body"
description: "bar object"
required: true
schema:
$ref: "#/definitions/Bar"
responses:
200:
description: "OK"
definitions:
Bar:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &barSpec)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
/bar:
post:
summary: "Bar API"
operationId: "barTest"
parameters:
- in: "body"
name: "body"
description: "bar object"
required: true
schema:
$ref: "#/definitions/Bar"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
Bar:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &expected)
ast := assert.New(t)
actual, _ := cloneSpec(fooSpec)
orig_barSpec, _ := cloneSpec(barSpec)
if !ast.Error(MergeSpecs(actual, barSpec)) {
return
}
ast.Equal(DebugSpec{orig_barSpec}, DebugSpec{barSpec}, "unexpected mutation of input")
actual, _ = cloneSpec(fooSpec)
if !ast.NoError(MergeSpecsIgnorePathConflictDeprecated(actual, barSpec)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{actual})
ast.Equal(DebugSpec{orig_barSpec}, DebugSpec{barSpec}, "unexpected mutation of input")
}
func TestMergeSpecsIgnorePathConflictsAllConflicting(t *testing.T) {
var fooSpec *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/foo:
post:
summary: "Foo API"
operationId: "fooTest"
parameters:
- in: "body"
name: "body"
description: "foo object"
required: true
schema:
$ref: "#/definitions/Foo"
responses:
200:
description: "OK"
definitions:
Foo:
type: "object"
properties:
id:
type: "integer"
format: "int64"
`), &fooSpec)
ast := assert.New(t)
foo2Spec, _ := cloneSpec(fooSpec)
actual, _ := cloneSpec(fooSpec)
if !ast.NoError(MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters(actual, foo2Spec)) {
return
}
ast.Equal(DebugSpec{fooSpec}, DebugSpec{actual})
ast.Equal(DebugSpec{fooSpec}, DebugSpec{foo2Spec}, "unexpected mutation of input")
}
func TestMergeSpecsIgnorePathConflictsWithKubeSpec(t *testing.T) {
ast := assert.New(t)
specs, expected := loadTestData()
sp, specs := specs[0], specs[1:]
origSpecs := make([]*spec.Swagger, len(specs))
for i := range specs {
cpy, err := cloneSpec(specs[i])
if err != nil {
t.Fatal(err)
}
ast.NoError(err)
origSpecs[i] = cpy
}
for i := range specs {
if err := MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters(sp, specs[i]); err != nil {
t.Fatalf("merging spec %d failed: %v", i, err)
}
}
ast.Equal(DebugSpec{expected}, DebugSpec{sp})
for i := range specs {
ast.Equal(DebugSpec{origSpecs[i]}, DebugSpec{specs[i]}, "unexpected mutation of specs[%d]", i)
}
}
func BenchmarkMergeSpecsIgnorePathConflictsWithKubeSpec(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.ResetTimer()
specs, _ := loadTestData()
start, specs := specs[0], specs[1:]
for n := 0; n < b.N; n++ {
sp, err := cloneSpec(start)
if err != nil {
b.Fatal(err)
}
b.StartTimer()
for i := range specs {
if err := MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters(sp, specs[i]); err != nil {
panic(err)
}
}
specBytes, _ := sp.MarshalJSON()
handler.ToProtoBinary(specBytes)
b.StopTimer()
}
}
func TestMergeSpecReplacesAllPossibleRefs(t *testing.T) {
var spec1, spec2, expected *spec.Swagger
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
definitions:
Test:
type: "object"
properties:
foo:
$ref: "#/definitions/TestProperty"
TestProperty:
type: "object"
`), &spec1)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test2:
post:
parameters:
- name: "test2"
schema:
$ref: "#/definitions/Test2"
- name: "test3"
schema:
$ref: "#/definitions/Test3"
- name: "test4"
schema:
$ref: "#/definitions/Test4"
- name: "test5"
schema:
$ref: "#/definitions/Test5"
definitions:
Test2:
$ref: "#/definitions/TestProperty"
Test3:
type: "object"
properties:
withRef:
$ref: "#/definitions/TestProperty"
withAllOf:
type: "object"
allOf:
- $ref: "#/definitions/TestProperty"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty"
withAnyOf:
type: "object"
anyOf:
- $ref: "#/definitions/TestProperty"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty"
withOneOf:
type: "object"
oneOf:
- $ref: "#/definitions/TestProperty"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty"
withNot:
type: "object"
not:
$ref: "#/definitions/TestProperty"
patternProperties:
"prefix.*":
$ref: "#/definitions/TestProperty"
additionalProperties:
$ref: "#/definitions/TestProperty"
definitions:
SomeDefinition:
$ref: "#/definitions/TestProperty"
Test4:
type: "array"
items:
$ref: "#/definitions/TestProperty"
additionalItems:
$ref: "#/definitions/TestProperty"
Test5:
type: "array"
items:
- $ref: "#/definitions/TestProperty"
- $ref: "#/definitions/TestProperty"
TestProperty:
description: "This TestProperty is different from the one in spec1"
type: "object"
`), &spec2)
yaml.Unmarshal([]byte(`
swagger: "2.0"
paths:
/test:
post:
parameters:
- name: "body"
schema:
$ref: "#/definitions/Test"
/test2:
post:
parameters:
- name: "test2"
schema:
$ref: "#/definitions/Test2"
- name: "test3"
schema:
$ref: "#/definitions/Test3"
- name: "test4"
schema:
$ref: "#/definitions/Test4"
- name: "test5"
schema:
$ref: "#/definitions/Test5"
definitions:
Test:
type: "object"
properties:
foo:
$ref: "#/definitions/TestProperty"
TestProperty:
type: "object"
Test2:
$ref: "#/definitions/TestProperty_v2"
Test3:
type: "object"
properties:
withRef:
$ref: "#/definitions/TestProperty_v2"
withAllOf:
type: "object"
allOf:
- $ref: "#/definitions/TestProperty_v2"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty_v2"
withAnyOf:
type: "object"
anyOf:
- $ref: "#/definitions/TestProperty_v2"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty_v2"
withOneOf:
type: "object"
oneOf:
- $ref: "#/definitions/TestProperty_v2"
- type: object
properties:
test:
$ref: "#/definitions/TestProperty_v2"
withNot:
type: "object"
not:
$ref: "#/definitions/TestProperty_v2"
patternProperties:
"prefix.*":
$ref: "#/definitions/TestProperty_v2"
additionalProperties:
$ref: "#/definitions/TestProperty_v2"
definitions:
SomeDefinition:
$ref: "#/definitions/TestProperty_v2"
Test4:
type: "array"
items:
$ref: "#/definitions/TestProperty_v2"
additionalItems:
$ref: "#/definitions/TestProperty_v2"
Test5:
type: "array"
items:
- $ref: "#/definitions/TestProperty_v2"
- $ref: "#/definitions/TestProperty_v2"
TestProperty_v2:
description: "This TestProperty is different from the one in spec1"
type: "object"
`), &expected)
ast := assert.New(t)
orig_spec2, _ := cloneSpec(spec2)
if !ast.NoError(MergeSpecs(spec1, spec2)) {
return
}
ast.Equal(DebugSpec{expected}, DebugSpec{spec1})
ast.Equal(DebugSpec{orig_spec2}, DebugSpec{spec2}, "unexpected mutation of input")
}
func loadTestData() ([]*spec.Swagger, *spec.Swagger) {
loadSpec := func(fileName string) *spec.Swagger {
bs, err := os.ReadFile(filepath.Join("../../test/integration/testdata/aggregator", fileName))
if err != nil {
panic(err)
}
sp := spec.Swagger{}
if err := json.Unmarshal(bs, &sp); err != nil {
panic(err)
}
return &sp
}
specs := []*spec.Swagger{
loadSpec("openapi-0.json"),
loadSpec("openapi-1.json"),
loadSpec("openapi-2.json"),
}
expected := loadSpec("openapi.json")
return specs, expected
}
func TestCloneSpec(t *testing.T) {
_, sp := loadTestData()
clone, err := cloneSpec(sp)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
ast := assert.New(t)
ast.Equal(DebugSpec{sp}, DebugSpec{clone})
}
func cloneSpec(source *spec.Swagger) (*spec.Swagger, error) {
bytes, err := source.MarshalJSON()
if err != nil {
return nil, err
}
var ret spec.Swagger
err = json.Unmarshal(bytes, &ret)
if err != nil {
return nil, err
}
return &ret, nil
}
func TestMergedGVKs(t *testing.T) {
gvk1 := map[string]interface{}{"group": "group1", "version": "v1", "kind": "Foo"}
gvk2 := map[string]interface{}{"group": "group2", "version": "v1", "kind": "Bar"}
gvk3 := map[string]interface{}{"group": "group3", "version": "v1", "kind": "Abc"}
gvk4 := map[string]interface{}{"group": "group4", "version": "v1", "kind": "Abc"}
tests := []struct {
name string
gvks1 interface{}
gvks2 interface{}
want interface{}
wantChanged bool
wantErr bool
}{
{"nil", nil, nil, nil, false, false},
{"first only", []interface{}{gvk1, gvk2}, nil, []interface{}{gvk1, gvk2}, false, false},
{"second only", nil, []interface{}{gvk1, gvk2}, []interface{}{gvk1, gvk2}, true, false},
{"both", []interface{}{gvk1, gvk2}, []interface{}{gvk3}, []interface{}{gvk1, gvk2, gvk3}, true, false},
{"equal, different order", []interface{}{gvk1, gvk2, gvk3}, []interface{}{gvk3, gvk2, gvk1}, []interface{}{gvk1, gvk2, gvk3}, false, false},
{"ordered", []interface{}{gvk3, gvk1, gvk4}, []interface{}{gvk2}, []interface{}{gvk1, gvk2, gvk3, gvk4}, true, false},
{"not ordered when not changed", []interface{}{gvk3, gvk1, gvk4}, []interface{}{}, []interface{}{gvk3, gvk1, gvk4}, false, false},
{"empty", []interface{}{}, []interface{}{}, []interface{}{}, false, false},
{"overlapping", []interface{}{gvk1, gvk2}, []interface{}{gvk2, gvk3}, []interface{}{gvk1, gvk2, gvk3}, true, false},
{"first no slice", 42, []interface{}{gvk1}, nil, false, true},
{"second no slice", []interface{}{gvk1}, 42, nil, false, true},
{"no map in slice", []interface{}{42}, []interface{}{gvk1}, nil, false, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var ext1, ext2 map[string]interface{}
if tt.gvks1 != nil {
ext1 = map[string]interface{}{"x-kubernetes-group-version-kind": tt.gvks1}
}
if tt.gvks2 != nil {
ext2 = map[string]interface{}{"x-kubernetes-group-version-kind": tt.gvks2}
}
got, gotChanged, gotErr := mergedGVKs(
&spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: ext1}},
&spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: ext2}},
)
if (gotErr != nil) != tt.wantErr {
t.Errorf("mergedGVKs() error = %v, wantErr %v", gotErr, tt.wantErr)
return
}
if gotChanged != tt.wantChanged {
t.Errorf("mergedGVKs() changed = %v, want %v", gotChanged, tt.wantChanged)
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("mergedGVKs() got = %v, want %v", got, tt.want)
}
})
}
}
func TestDeepEqualDefinitionsModuloGVKs(t *testing.T) {
tests := []struct {
name string
s1 *spec.Schema
s2 *spec.Schema
equal bool
}{
{name: "nil", equal: true},
{name: "nil, non-nil", s1: nil, s2: &spec.Schema{}},
{name: "equal", s1: &spec.Schema{}, s2: &spec.Schema{}, equal: true},
{name: "different", s1: &spec.Schema{SchemaProps: spec.SchemaProps{ID: "abc"}}, s2: &spec.Schema{}},
{name: "equal modulo: nil, empty",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: nil}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{}}},
equal: true,
},
{name: "equal modulo: nil, gvk",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: nil}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
}}},
equal: true,
},
{name: "equal modulo: empty, gvk",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{}}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
}}},
equal: true,
},
{name: "equal modulo: non-empty, gvk",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{"foo": "bar"}}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
"foo": "bar",
}}},
equal: true,
},
{name: "equal modulo: gvk, gvk",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: false,
"foo": "bar",
}}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
"foo": "bar",
}}},
equal: true,
},
{name: "different values",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: false,
"foo": "bar",
}}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
"foo": "abc",
}}},
},
{name: "different sizes",
s1: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: false,
"foo": "bar",
"xyz": "123",
}}},
s2: &spec.Schema{VendorExtensible: spec.VendorExtensible{Extensions: spec.Extensions{
gvkKey: true,
"foo": "abc",
}}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := deepEqualDefinitionsModuloGVKs(tt.s1, tt.s2); got != tt.equal {
t.Errorf("deepEqualDefinitionsModuloGVKs(s1, v2) = %v, want %v", got, tt.equal)
}
if got := deepEqualDefinitionsModuloGVKs(tt.s2, tt.s1); got != tt.equal {
t.Errorf("deepEqualDefinitionsModuloGVKs(s2, s1) = %v, want %v", got, tt.equal)
}
})
}
}
================================================
FILE: pkg/aggregator/walker.go
================================================
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package aggregator
import (
"strings"
"k8s.io/kube-openapi/pkg/validation/spec"
)
const (
definitionPrefix = "#/definitions/"
parameterPrefix = "#/parameters/"
)
// Run a readonlyReferenceWalker method on all references of an OpenAPI spec
type readonlyReferenceWalker struct {
// walkRefCallback will be called on each reference. The input will never be nil.
walkRefCallback func(ref *spec.Ref)
// The spec to walk through.
root *spec.Swagger
}
// walkOnAllReferences recursively walks on all references, while following references into definitions.
// it calls walkRef on each found reference.
func walkOnAllReferences(walkRef func(ref *spec.Ref), root *spec.Swagger) {
alreadyVisited := map[string]bool{}
walker := &readonlyReferenceWalker{
root: root,
}
walker.walkRefCallback = func(ref *spec.Ref) {
walkRef(ref)
refStr := ref.String()
if refStr == "" {
return
}
if strings.HasPrefix(refStr, parameterPrefix) {
paramName := refStr[len(parameterPrefix):]
if param, found := root.Parameters[paramName]; found {
walker.walkParam(param)
}
} else if strings.HasPrefix(refStr, definitionPrefix) {
defName := refStr[len(definitionPrefix):]
if _, found := root.Definitions[defName]; found && !alreadyVisited[refStr] {
alreadyVisited[refStr] = true
def := root.Definitions[defName]
walker.walkSchema(&def)
}
}
}
walker.Start()
}
func (s *readonlyReferenceWalker) walkSchema(schema *spec.Schema) {
if schema == nil {
return
}
s.walkRefCallback(&schema.Ref)
var v *spec.Schema
if len(schema.Definitions)+len(schema.Properties)+len(schema.PatternProperties) > 0 {
v = &spec.Schema{}
}
for k := range schema.Definitions {
*v = schema.Definitions[k]
s.walkSchema(v)
}
for k := range schema.Properties {
*v = schema.Properties[k]
s.walkSchema(v)
}
for k := range schema.PatternProperties {
*v = schema.PatternProperties[k]
s.walkSchema(v)
}
for i := range schema.AllOf {
s.walkSchema(&schema.AllOf[i])
}
for i := range schema.AnyOf {
s.walkSchema(&schema.AnyOf[i])
}
for i := range schema.OneOf {
s.walkSchema(&schema.OneOf[i])
}
if schema.Not != nil {
s.walkSchema(schema.Not)
}
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
s.walkSchema(schema.AdditionalProperties.Schema)
}
if schema.AdditionalItems != nil && schema.AdditionalItems.Schema != nil {
s.walkSchema(schema.AdditionalItems.Schema)
}
if schema.Items != nil {
if schema.Items.Schema != nil {
s.walkSchema(schema.Items.Schema)
}
for i := range schema.Items.Schemas {
s.walkSchema(&schema.Items.Schemas[i])
}
}
}
func (s *readonlyReferenceWalker) walkParams(params []spec.Parameter) {
if params == nil {
return
}
for _, param := range params {
s.walkParam(param)
}
}
func (s *readonlyReferenceWalker) walkParam(param spec.Parameter) {
s.walkRefCallback(¶m.Ref)
s.walkSchema(param.Schema)
if param.Items != nil {
s.walkRefCallback(¶m.Items.Ref)
}
}
func (s *readonlyReferenceWalker) walkResponse(resp *spec.Response) {
if resp == nil {
return
}
s.walkRefCallback(&resp.Ref)
s.walkSchema(resp.Schema)
}
func (s *readonlyReferenceWalker) walkOperation(op *spec.Operation) {
if op == nil {
return
}
s.walkParams(op.Parameters)
if op.Responses == nil {
return
}
s.walkResponse(op.Responses.Default)
for _, r := range op.Responses.StatusCodeResponses {
s.walkResponse(&r)
}
}
func (s *readonlyReferenceWalker) Start() {
if s.root.Paths == nil {
return
}
for _, pathItem := range s.root.Paths.Paths {
s.walkParams(pathItem.Parameters)
s.walkOperation(pathItem.Delete)
s.walkOperation(pathItem.Get)
s.walkOperation(pathItem.Head)
s.walkOperation(pathItem.Options)
s.walkOperation(pathItem.Patch)
s.walkOperation(pathItem.Post)
s.walkOperation(pathItem.Put)
}
}
================================================
FILE: pkg/builder/doc.go
================================================
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package builder contains code to generate OpenAPI discovery spec (which
// initial version of it also known as Swagger 2.0).
// For more details: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
package builder
================================================
FILE: pkg/builder/openapi.go
================================================
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"encoding/json"
"fmt"
"net/http"
"strings"
restful "github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/common/restfuladapter"
"k8s.io/kube-openapi/pkg/util"
"k8s.io/kube-openapi/pkg/validation/spec"
)
const (
OpenAPIVersion = "2.0"
)
type openAPI struct {
config *common.Config
swagger *spec.Swagger
protocolList []string
definitions map[string]common.OpenAPIDefinition
}
// BuildOpenAPISpec builds OpenAPI spec given a list of route containers and common.Config to customize it.
//
// Deprecated: BuildOpenAPISpecFromRoutes should be used instead.
func BuildOpenAPISpec(routeContainers []*restful.WebService, config *common.Config) (*spec.Swagger, error) {
return BuildOpenAPISpecFromRoutes(restfuladapter.AdaptWebServices(routeContainers), config)
}
// BuildOpenAPISpecFromRoutes builds OpenAPI spec given a list of route containers and common.Config to customize it.
func BuildOpenAPISpecFromRoutes(routeContainers []common.RouteContainer, config *common.Config) (*spec.Swagger, error) {
o := newOpenAPI(config)
err := o.buildPaths(routeContainers)
if err != nil {
return nil, err
}
return o.finalizeSwagger()
}
// BuildOpenAPIDefinitionsForResource builds a partial OpenAPI spec given a sample object and common.Config to customize it.
func BuildOpenAPIDefinitionsForResource(model interface{}, config *common.Config) (*spec.Definitions, error) {
o := newOpenAPI(config)
// We can discard the return value of toSchema because all we care about is the side effect of calling it.
// All the models created for this resource get added to o.swagger.Definitions
_, err := o.toSchema(util.GetCanonicalTypeName(model))
if err != nil {
return nil, err
}
swagger, err := o.finalizeSwagger()
if err != nil {
return nil, err
}
return &swagger.Definitions, nil
}
// BuildOpenAPIDefinitionsForResources returns the OpenAPI spec which includes the definitions for the
// passed type names.
func BuildOpenAPIDefinitionsForResources(config *common.Config, names ...string) (*spec.Swagger, error) {
o := newOpenAPI(config)
// We can discard the return value of toSchema because all we care about is the side effect of calling it.
// All the models created for this resource get added to o.swagger.Definitions
for _, name := range names {
_, err := o.toSchema(name)
if err != nil {
return nil, err
}
}
return o.finalizeSwagger()
}
// newOpenAPI sets up the openAPI object so we can build the spec.
func newOpenAPI(config *common.Config) openAPI {
o := openAPI{
config: config,
swagger: &spec.Swagger{
SwaggerProps: spec.SwaggerProps{
Swagger: OpenAPIVersion,
Definitions: spec.Definitions{},
Responses: config.ResponseDefinitions,
Paths: &spec.Paths{Paths: map[string]spec.PathItem{}},
Info: config.Info,
},
},
}
if o.config.GetOperationIDAndTagsFromRoute == nil {
// Map the deprecated handler to the common interface, if provided.
if o.config.GetOperationIDAndTags != nil {
o.config.GetOperationIDAndTagsFromRoute = func(r common.Route) (string, []string, error) {
restfulRouteAdapter, ok := r.(*restfuladapter.RouteAdapter)
if !ok {
return "", nil, fmt.Errorf("config.GetOperationIDAndTags specified but route is not a restful v1 Route")
}
return o.config.GetOperationIDAndTags(restfulRouteAdapter.Route)
}
} else {
o.config.GetOperationIDAndTagsFromRoute = func(r common.Route) (string, []string, error) {
return r.OperationName(), nil, nil
}
}
}
if o.config.GetDefinitionName == nil {
o.config.GetDefinitionName = func(name string) (string, spec.Extensions) {
return name[strings.LastIndex(name, "/")+1:], nil
}
}
o.definitions = o.config.GetDefinitions(func(name string) spec.Ref {
defName, _ := o.config.GetDefinitionName(name)
return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(defName))
})
if o.config.CommonResponses == nil {
o.config.CommonResponses = map[int]spec.Response{}
}
return o
}
// finalizeSwagger is called after the spec is built and returns the final spec.
// NOTE: finalizeSwagger also make changes to the final spec, as specified in the config.
func (o *openAPI) finalizeSwagger() (*spec.Swagger, error) {
if o.config.SecurityDefinitions != nil {
o.swagger.SecurityDefinitions = *o.config.SecurityDefinitions
o.swagger.Security = o.config.DefaultSecurity
}
if o.config.PostProcessSpec != nil {
var err error
o.swagger, err = o.config.PostProcessSpec(o.swagger)
if err != nil {
return nil, err
}
}
return deduplicateParameters(o.swagger)
}
func (o *openAPI) buildDefinitionRecursively(name string) error {
uniqueName, extensions := o.config.GetDefinitionName(name)
escapedName := common.EscapeJsonPointer(uniqueName)
if _, ok := o.swagger.Definitions[escapedName]; ok {
return nil
}
if item, ok := o.definitions[name]; ok {
schema := spec.Schema{
VendorExtensible: item.Schema.VendorExtensible,
SchemaProps: item.Schema.SchemaProps,
SwaggerSchemaProps: item.Schema.SwaggerSchemaProps,
}
if extensions != nil {
if schema.Extensions == nil {
schema.Extensions = spec.Extensions{}
}
for k, v := range extensions {
schema.Extensions[k] = v
}
}
if v, ok := item.Schema.Extensions[common.ExtensionV2Schema]; ok {
if v2Schema, isOpenAPISchema := v.(spec.Schema); isOpenAPISchema {
schema = v2Schema
}
}
o.swagger.Definitions[escapedName] = schema
for _, v := range item.Dependencies {
if err := o.buildDefinitionRecursively(v); err != nil {
return err
}
}
} else {
return fmt.Errorf("cannot find model definition for %v. If you added a new type, you may need to add +k8s:openapi-gen=true to the package or type and run code-gen again", name)
}
return nil
}
// buildDefinitionForType build a definition for a given type and return a referable name to its definition.
// This is the main function that keep track of definitions used in this spec and is depend on code generated
// by k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen.
func (o *openAPI) buildDefinitionForType(name string) (string, error) {
if err := o.buildDefinitionRecursively(name); err != nil {
return "", err
}
defName, _ := o.config.GetDefinitionName(name)
return "#/definitions/" + common.EscapeJsonPointer(defName), nil
}
// buildPaths builds OpenAPI paths using go-restful's web services.
func (o *openAPI) buildPaths(routeContainers []common.RouteContainer) error {
pathsToIgnore := util.NewTrie(o.config.IgnorePrefixes)
duplicateOpId := make(map[string]string)
for _, w := range routeContainers {
rootPath := w.RootPath()
if pathsToIgnore.HasPrefix(rootPath) {
continue
}
commonParams, err := o.buildParameters(w.PathParameters())
if err != nil {
return err
}
for path, routes := range groupRoutesByPath(w.Routes()) {
// go-swagger has special variable definition {$NAME:*} that can only be
// used at the end of the path and it is not recognized by OpenAPI.
if strings.HasSuffix(path, ":*}") {
path = path[:len(path)-3] + "}"
}
if pathsToIgnore.HasPrefix(path) {
continue
}
// Aggregating common parameters make API spec (and generated clients) simpler
inPathCommonParamsMap, err := o.findCommonParameters(routes)
if err != nil {
return err
}
pathItem, exists := o.swagger.Paths.Paths[path]
if exists {
return fmt.Errorf("duplicate webservice route has been found for path: %v", path)
}
pathItem = spec.PathItem{
PathItemProps: spec.PathItemProps{
Parameters: make([]spec.Parameter, 0),
},
}
// add web services's parameters as well as any parameters appears in all ops, as common parameters
pathItem.Parameters = append(pathItem.Parameters, commonParams...)
for _, p := range inPathCommonParamsMap {
pathItem.Parameters = append(pathItem.Parameters, p)
}
sortParameters(pathItem.Parameters)
for _, route := range routes {
op, err := o.buildOperations(route, inPathCommonParamsMap)
sortParameters(op.Parameters)
if err != nil {
return err
}
dpath, exists := duplicateOpId[op.ID]
if exists {
return fmt.Errorf("duplicate Operation ID %v for path %v and %v", op.ID, dpath, path)
} else {
duplicateOpId[op.ID] = path
}
switch strings.ToUpper(route.Method()) {
case "GET":
pathItem.Get = op
case "POST":
pathItem.Post = op
case "HEAD":
pathItem.Head = op
case "PUT":
pathItem.Put = op
case "DELETE":
pathItem.Delete = op
case "OPTIONS":
pathItem.Options = op
case "PATCH":
pathItem.Patch = op
}
}
o.swagger.Paths.Paths[path] = pathItem
}
}
return nil
}
// buildOperations builds operations for each webservice path
func (o *openAPI) buildOperations(route common.Route, inPathCommonParamsMap map[interface{}]spec.Parameter) (ret *spec.Operation, err error) {
ret = &spec.Operation{
OperationProps: spec.OperationProps{
Description: route.Description(),
Consumes: route.Consumes(),
Produces: route.Produces(),
Schemes: o.config.ProtocolList,
Responses: &spec.Responses{
ResponsesProps: spec.ResponsesProps{
StatusCodeResponses: make(map[int]spec.Response),
},
},
},
}
for k, v := range route.Metadata() {
if strings.HasPrefix(k, common.ExtensionPrefix) {
if ret.Extensions == nil {
ret.Extensions = spec.Extensions{}
}
ret.Extensions.Add(k, v)
}
}
if ret.ID, ret.Tags, err = o.config.GetOperationIDAndTagsFromRoute(route); err != nil {
return ret, err
}
// Build responses
for _, resp := range route.StatusCodeResponses() {
ret.Responses.StatusCodeResponses[resp.Code()], err = o.buildResponse(resp.Model(), resp.Message())
if err != nil {
return ret, err
}
}
// If there is no response but a write sample, assume that write sample is an http.StatusOK response.
if len(ret.Responses.StatusCodeResponses) == 0 && route.ResponsePayloadSample() != nil {
ret.Responses.StatusCodeResponses[http.StatusOK], err = o.buildResponse(route.ResponsePayloadSample(), "OK")
if err != nil {
return ret, err
}
}
for code, resp := range o.config.CommonResponses {
if _, exists := ret.Responses.StatusCodeResponses[code]; !exists {
ret.Responses.StatusCodeResponses[code] = resp
}
}
// If there is still no response, use default response provided.
if len(ret.Responses.StatusCodeResponses) == 0 {
ret.Responses.Default = o.config.DefaultResponse
}
// Build non-common Parameters
ret.Parameters = make([]spec.Parameter, 0)
for _, param := range route.Parameters() {
if _, isCommon := inPathCommonParamsMap[mapKeyFromParam(param)]; !isCommon {
openAPIParam, err := o.buildParameter(param, route.RequestPayloadSample())
if err != nil {
return ret, err
}
ret.Parameters = append(ret.Parameters, openAPIParam)
}
}
return ret, nil
}
func (o *openAPI) buildResponse(model interface{}, description string) (spec.Response, error) {
schema, err := o.toSchema(util.GetCanonicalTypeName(model))
if err != nil {
return spec.Response{}, err
}
return spec.Response{
ResponseProps: spec.ResponseProps{
Description: description,
Schema: schema,
},
}, nil
}
func (o *openAPI) findCommonParameters(routes []common.Route) (map[interface{}]spec.Parameter, error) {
commonParamsMap := make(map[interface{}]spec.Parameter, 0)
paramOpsCountByName := make(map[interface{}]int, 0)
paramNameKindToDataMap := make(map[interface{}]common.Parameter, 0)
for _, route := range routes {
routeParamDuplicateMap := make(map[interface{}]bool)
s := ""
params := route.Parameters()
for _, param := range params {
m, _ := json.Marshal(param)
s += string(m) + "\n"
key := mapKeyFromParam(param)
if routeParamDuplicateMap[key] {
msg, _ := json.Marshal(params)
return commonParamsMap, fmt.Errorf("duplicate parameter %v for route %v, %v", param.Name(), string(msg), s)
}
routeParamDuplicateMap[key] = true
paramOpsCountByName[key]++
paramNameKindToDataMap[key] = param
}
}
for key, count := range paramOpsCountByName {
paramData := paramNameKindToDataMap[key]
if count == len(routes) && paramData.Kind() != common.BodyParameterKind {
openAPIParam, err := o.buildParameter(paramData, nil)
if err != nil {
return commonParamsMap, err
}
commonParamsMap[key] = openAPIParam
}
}
return commonParamsMap, nil
}
func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) {
if openAPIType, openAPIFormat := common.OpenAPITypeFormat(name); openAPIType != "" {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{openAPIType},
Format: openAPIFormat,
},
}, nil
} else {
ref, err := o.buildDefinitionForType(name)
if err != nil {
return nil, err
}
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef(ref),
},
}, nil
}
}
func (o *openAPI) buildParameter(restParam common.Parameter, bodySample interface{}) (ret spec.Parameter, err error) {
ret = spec.Parameter{
ParamProps: spec.ParamProps{
Name: restParam.Name(),
Description: restParam.Description(),
Required: restParam.Required(),
},
}
switch restParam.Kind() {
case common.BodyParameterKind:
if bodySample != nil {
ret.In = "body"
ret.Schema, err = o.toSchema(util.GetCanonicalTypeName(bodySample))
return ret, err
} else {
// There is not enough information in the body parameter to build the definition.
// Body parameter has a data type that is a short name but we need full package name
// of the type to create a definition.
return ret, fmt.Errorf("restful body parameters are not supported: %v", restParam.DataType())
}
case common.PathParameterKind:
ret.In = "path"
if !restParam.Required() {
return ret, fmt.Errorf("path parameters should be marked at required for parameter %v", restParam)
}
case common.QueryParameterKind:
ret.In = "query"
case common.HeaderParameterKind:
ret.In = "header"
case common.FormParameterKind:
ret.In = "formData"
default:
return ret, fmt.Errorf("unknown restful operation kind : %v", restParam.Kind())
}
openAPIType, openAPIFormat := common.OpenAPITypeFormat(restParam.DataType())
if openAPIType == "" {
return ret, fmt.Errorf("non-body Restful parameter type should be a simple type, but got : %v", restParam.DataType())
}
ret.Type = openAPIType
ret.Format = openAPIFormat
ret.UniqueItems = !restParam.AllowMultiple()
return ret, nil
}
func (o *openAPI) buildParameters(restParam []common.Parameter) (ret []spec.Parameter, err error) {
ret = make([]spec.Parameter, len(restParam))
for i, v := range restParam {
ret[i], err = o.buildParameter(v, nil)
if err != nil {
return ret, err
}
}
return ret, nil
}
================================================
FILE: pkg/builder/openapi_test.go
================================================
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"encoding/json"
"fmt"
"net/http"
"strings"
"testing"
"github.com/emicklei/go-restful/v3"
"github.com/stretchr/testify/assert"
openapi "k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/util/jsontesting"
"k8s.io/kube-openapi/pkg/validation/spec"
)
// setUp is a convenience function for setting up for (most) tests.
func setUp(t *testing.T, fullMethods bool) (*openapi.Config, *restful.Container, *assert.Assertions) {
assert := assert.New(t)
config, container := getConfig(fullMethods)
return config, container, assert
}
func noOp(request *restful.Request, response *restful.Response) {}
// Test input
type TestInput struct {
// Name of the input
Name string `json:"name,omitempty"`
// ID of the input
ID int `json:"id,omitempty"`
Tags []string `json:"tags,omitempty"`
}
// Test output
type TestOutput struct {
// Name of the output
Name string `json:"name,omitempty"`
// Number of outputs
Count int `json:"count,omitempty"`
}
type TestExtensionV2Schema struct{}
func (_ TestExtensionV2Schema) OpenAPIDefinition() openapi.OpenAPIDefinition {
schema := spec.Schema{
VendorExtensible: spec.VendorExtensible{
Extensions: map[string]interface{}{
openapi.ExtensionV2Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"integer"},
},
},
},
},
}
schema.Description = "Test extension V2 spec conversion"
schema.Properties = map[string]spec.Schema{
"apple": {
SchemaProps: spec.SchemaProps{
Description: "Name of the output",
Type: []string{"string"},
Format: "",
},
},
}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{},
}
}
func (_ TestInput) OpenAPIDefinition() openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test input"
schema.Properties = map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the input",
Type: []string{"string"},
Format: "",
},
},
"id": {
SchemaProps: spec.SchemaProps{
Description: "ID of the input",
Type: []string{"integer"},
Format: "int32",
},
},
"tags": {
SchemaProps: spec.SchemaProps{
Description: "",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
}
schema.Extensions = spec.Extensions{"x-test": "test"}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{},
}
}
func (_ TestOutput) OpenAPIDefinition() openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test output"
schema.Properties = map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the output",
Type: []string{"string"},
Format: "",
},
},
"count": {
SchemaProps: spec.SchemaProps{
Description: "Number of outputs",
Type: []string{"integer"},
Format: "int32",
},
},
}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{},
}
}
var _ openapi.OpenAPIDefinitionGetter = TestInput{}
var _ openapi.OpenAPIDefinitionGetter = TestOutput{}
func getTestRoute(ws *restful.WebService, method string, additionalParams bool, opPrefix string) *restful.RouteBuilder {
ret := ws.Method(method).
Path("/test/{path:*}").
Doc(fmt.Sprintf("%s test input", method)).
Operation(fmt.Sprintf("%s%sTestInput", method, opPrefix)).
Produces(restful.MIME_JSON).
Consumes(restful.MIME_JSON).
Param(ws.PathParameter("path", "path to the resource").DataType("string")).
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
Reads(TestInput{}).
Returns(200, "OK", TestOutput{}).
Writes(TestOutput{}).
To(noOp)
if additionalParams {
ret.Param(ws.HeaderParameter("hparam", "a test head parameter").DataType("integer"))
ret.Param(ws.FormParameter("fparam", "a test form parameter").DataType("number"))
}
return ret
}
func getConfig(fullMethods bool) (*openapi.Config, *restful.Container) {
mux := http.NewServeMux()
container := restful.NewContainer()
container.ServeMux = mux
ws := new(restful.WebService)
ws.Path("/foo")
ws.Route(getTestRoute(ws, "get", true, "foo"))
if fullMethods {
ws.Route(getTestRoute(ws, "post", false, "foo")).
Route(getTestRoute(ws, "put", false, "foo")).
Route(getTestRoute(ws, "head", false, "foo")).
Route(getTestRoute(ws, "patch", false, "foo")).
Route(getTestRoute(ws, "options", false, "foo")).
Route(getTestRoute(ws, "delete", false, "foo"))
}
ws.Path("/bar")
ws.Route(getTestRoute(ws, "get", true, "bar"))
if fullMethods {
ws.Route(getTestRoute(ws, "post", false, "bar")).
Route(getTestRoute(ws, "put", false, "bar")).
Route(getTestRoute(ws, "head", false, "bar")).
Route(getTestRoute(ws, "patch", false, "bar")).
Route(getTestRoute(ws, "options", false, "bar")).
Route(getTestRoute(ws, "delete", false, "bar"))
}
container.Add(ws)
return &openapi.Config{
ProtocolList: []string{"https"},
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "unversioned",
},
},
GetDefinitions: func(_ openapi.ReferenceCallback) map[string]openapi.OpenAPIDefinition {
return map[string]openapi.OpenAPIDefinition{
"k8s.io/kube-openapi/pkg/builder.TestInput": TestInput{}.OpenAPIDefinition(),
"k8s.io/kube-openapi/pkg/builder.TestOutput": TestOutput{}.OpenAPIDefinition(),
"k8s.io/kube-openapi/pkg/builder.TestExtensionV2Schema": TestExtensionV2Schema{}.OpenAPIDefinition(),
}
},
GetDefinitionName: func(name string) (string, spec.Extensions) {
friendlyName := name[strings.LastIndex(name, "/")+1:]
return friendlyName, spec.Extensions{"x-test2": "test2"}
},
}, container
}
func getTestOperation(method string, opPrefix string) *spec.Operation {
return &spec.Operation{
OperationProps: spec.OperationProps{
Description: fmt.Sprintf("%s test input", method),
Consumes: []string{"application/json"},
Produces: []string{"application/json"},
Schemes: []string{"https"},
Parameters: []spec.Parameter{},
Responses: getTestResponses(),
ID: fmt.Sprintf("%s%sTestInput", method, opPrefix),
},
}
}
func getTestPathItem(allMethods bool, opPrefix string) spec.PathItem {
ret := spec.PathItem{
PathItemProps: spec.PathItemProps{
Get: getTestOperation("get", opPrefix),
Parameters: getTestCommonParameters(),
},
}
ret.Get.Parameters = getAdditionalTestParameters()
if allMethods {
ret.Put = getTestOperation("put", opPrefix)
ret.Put.Parameters = getTestParameters()
ret.Post = getTestOperation("post", opPrefix)
ret.Post.Parameters = getTestParameters()
ret.Head = getTestOperation("head", opPrefix)
ret.Head.Parameters = getTestParameters()
ret.Patch = getTestOperation("patch", opPrefix)
ret.Patch.Parameters = getTestParameters()
ret.Delete = getTestOperation("delete", opPrefix)
ret.Delete.Parameters = getTestParameters()
ret.Options = getTestOperation("options", opPrefix)
ret.Options.Parameters = getTestParameters()
}
return ret
}
func getRefSchema(ref string) *spec.Schema {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef(ref),
},
}
}
func getTestResponses() *spec.Responses {
ret := spec.Responses{
ResponsesProps: spec.ResponsesProps{
StatusCodeResponses: map[int]spec.Response{},
},
}
ret.StatusCodeResponses[200] = spec.Response{
ResponseProps: spec.ResponseProps{
Description: "OK",
Schema: getRefSchema("#/definitions/builder.TestOutput"),
},
}
return &ret
}
func getTestCommonParameters() []spec.Parameter {
ret := make([]spec.Parameter, 2)
ret[0] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/path-z6Ciiujn"),
},
}
ret[1] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/pretty-nN7o5FEq"),
},
}
return ret
}
func getTestParameters() []spec.Parameter {
ret := make([]spec.Parameter, 1)
ret[0] = spec.Parameter{
ParamProps: spec.ParamProps{
In: "body",
Name: "body",
Required: true,
Schema: getRefSchema("#/definitions/builder.TestInput"),
},
}
return ret
}
func getAdditionalTestParameters() []spec.Parameter {
ret := make([]spec.Parameter, 3)
ret[0] = spec.Parameter{
ParamProps: spec.ParamProps{
In: "body",
Name: "body",
Required: true,
Schema: getRefSchema("#/definitions/builder.TestInput"),
},
}
ret[1] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/fparam-xCJg5kHS"),
},
}
ret[2] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/hparam-tx-jfxM1"),
},
}
return ret
}
func getTestInputDefinition() spec.Schema {
return spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Test input",
Properties: map[string]spec.Schema{
"id": {
SchemaProps: spec.SchemaProps{
Description: "ID of the input",
Type: spec.StringOrArray{"integer"},
Format: "int32",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the input",
Type: spec.StringOrArray{"string"},
},
},
"tags": {
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"string"},
},
},
},
},
},
},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-test": "test",
"x-test2": "test2",
},
},
}
}
func getTestOutputDefinition() spec.Schema {
return spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Test output",
Properties: map[string]spec.Schema{
"count": {
SchemaProps: spec.SchemaProps{
Description: "Number of outputs",
Type: spec.StringOrArray{"integer"},
Format: "int32",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the output",
Type: spec.StringOrArray{"string"},
},
},
},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-test2": "test2",
},
},
}
}
func TestBuildOpenAPISpec(t *testing.T) {
config, container, assert := setUp(t, true)
expected := &spec.Swagger{
SwaggerProps: spec.SwaggerProps{
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "unversioned",
},
},
Swagger: "2.0",
Paths: &spec.Paths{
Paths: map[string]spec.PathItem{
"/foo/test/{path}": getTestPathItem(true, "foo"),
"/bar/test/{path}": getTestPathItem(true, "bar"),
},
},
Definitions: spec.Definitions{
"builder.TestInput": getTestInputDefinition(),
"builder.TestOutput": getTestOutputDefinition(),
},
Parameters: map[string]spec.Parameter{
"fparam-xCJg5kHS": {
CommonValidations: spec.CommonValidations{
UniqueItems: true,
},
SimpleSchema: spec.SimpleSchema{
Type: "number",
},
ParamProps: spec.ParamProps{
In: "formData",
Name: "fparam",
Description: "a test form parameter",
},
},
"hparam-tx-jfxM1": {
CommonValidations: spec.CommonValidations{
UniqueItems: true,
},
SimpleSchema: spec.SimpleSchema{
Type: "integer",
},
ParamProps: spec.ParamProps{
In: "header",
Name: "hparam",
Description: "a test head parameter",
},
},
"path-z6Ciiujn": {
CommonValidations: spec.CommonValidations{
UniqueItems: true,
},
SimpleSchema: spec.SimpleSchema{
Type: "string",
},
ParamProps: spec.ParamProps{
In: "path",
Name: "path",
Description: "path to the resource",
Required: true,
},
},
"pretty-nN7o5FEq": {
CommonValidations: spec.CommonValidations{
UniqueItems: true,
},
SimpleSchema: spec.SimpleSchema{
Type: "string",
},
ParamProps: spec.ParamProps{
In: "query",
Name: "pretty",
Description: "If 'true', then the output is pretty printed.",
},
},
},
},
}
swagger, err := BuildOpenAPISpec(container.RegisteredWebServices(), config)
if !assert.NoError(err) {
return
}
expected_json, err := expected.MarshalJSON()
if !assert.NoError(err) {
return
}
actual_json, err := swagger.MarshalJSON()
if !assert.NoError(err) {
return
}
if err := jsontesting.JsonCompare(expected_json, actual_json); err != nil {
t.Error(err)
}
}
func TestBuildOpenAPIDefinitionsForResource(t *testing.T) {
config, _, assert := setUp(t, true)
expected := &spec.Definitions{
"builder.TestInput": getTestInputDefinition(),
}
swagger, err := BuildOpenAPIDefinitionsForResource(TestInput{}, config)
if !assert.NoError(err) {
return
}
expected_json, err := json.Marshal(expected)
if !assert.NoError(err) {
return
}
actual_json, err := json.Marshal(swagger)
if !assert.NoError(err) {
return
}
if err := jsontesting.JsonCompare(expected_json, actual_json); err != nil {
t.Error(err)
}
}
func TestBuildOpenAPIDefinitionsForResourceWithExtensionV2Schema(t *testing.T) {
config, _, assert := setUp(t, true)
expected := &spec.Definitions{
"builder.TestExtensionV2Schema": spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"integer"},
},
},
}
swagger, err := BuildOpenAPIDefinitionsForResource(TestExtensionV2Schema{}, config)
if !assert.NoError(err) {
return
}
expected_json, err := json.Marshal(expected)
if !assert.NoError(err) {
return
}
actual_json, err := json.Marshal(swagger)
if !assert.NoError(err) {
return
}
assert.Equal(string(expected_json), string(actual_json))
}
type TestRecursiveType struct {
Value string `json:"value,omitempty"`
Children []TestRecursiveType `json:"children,omitempty"`
}
func makeRecursiveTypeDefinition(depName string) openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test recursive type for JSON pointer escaping"
schema.Properties = map[string]spec.Schema{
"value": {
SchemaProps: spec.SchemaProps{
Description: "A test value",
Type: []string{"string"},
},
},
"children": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("#/definitions/" + depName),
},
},
},
},
},
}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{depName},
}
}
func TestEscapeJsonPointerInDefinitionName(t *testing.T) {
testCases := []struct {
name string
definitionName string
expectedName string
shouldNotExist string
}{
{
name: "both slash and tilde",
definitionName: "io.k8s/api~v1.TestRecursiveType",
expectedName: "io.k8s~1api~0v1.TestRecursiveType",
shouldNotExist: "io.k8s/api~v1.TestRecursiveType",
},
{
name: "only slashes",
definitionName: "io.k8s/api/v1.TestRecursiveType",
expectedName: "io.k8s~1api~1v1.TestRecursiveType",
shouldNotExist: "io.k8s/api/v1.TestRecursiveType",
},
{
name: "only tildes",
definitionName: "io.k8s~api~v1.TestRecursiveType",
expectedName: "io.k8s~0api~0v1.TestRecursiveType",
shouldNotExist: "io.k8s~api~v1.TestRecursiveType",
},
{
name: "no special characters",
definitionName: "io.k8s.api.v1.TestRecursiveType",
expectedName: "io.k8s.api.v1.TestRecursiveType",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
config := &openapi.Config{
ProtocolList: []string{"https"},
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "v1",
},
},
GetDefinitions: func(_ openapi.ReferenceCallback) map[string]openapi.OpenAPIDefinition {
return map[string]openapi.OpenAPIDefinition{
tc.definitionName: makeRecursiveTypeDefinition(tc.definitionName),
}
},
GetDefinitionName: func(name string) (string, spec.Extensions) {
return name, nil
},
}
definitions, err := BuildOpenAPIDefinitionsForResources(config, tc.definitionName)
assert.NoError(err)
assert.NotNil(definitions)
_, exists := definitions.Definitions[tc.expectedName]
assert.True(exists, "Definition should exist with escaped name: %s", tc.expectedName)
if tc.shouldNotExist != "" {
_, exists = definitions.Definitions[tc.shouldNotExist]
assert.False(exists, "Definition should not exist with unescaped name: %s", tc.shouldNotExist)
}
})
}
}
================================================
FILE: pkg/builder/parameters.go
================================================
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"encoding/base64"
"encoding/json"
"fmt"
"hash/fnv"
"sort"
"strconv"
"strings"
"k8s.io/kube-openapi/pkg/validation/spec"
)
// deduplicateParameters finds parameters that are shared across multiple endpoints and replace them with
// references to the shared parameters in order to avoid repetition.
//
// deduplicateParameters does not mutate the source.
func deduplicateParameters(sp *spec.Swagger) (*spec.Swagger, error) {
names, parameters, err := collectSharedParameters(sp)
if err != nil {
return nil, err
}
if sp.Parameters != nil {
return nil, fmt.Errorf("shared parameters already exist") // should not happen with the builder, but to be sure
}
clone := *sp
clone.Parameters = parameters
return replaceSharedParameters(names, &clone)
}
// collectSharedParameters finds parameters that show up for many endpoints. These
// are basically all parameters with the exceptions of those where we know they are
// endpoint specific, e.g. because they reference the schema of the kind, or have
// the kind or resource name in the description.
func collectSharedParameters(sp *spec.Swagger) (namesByJSON map[string]string, ret map[string]spec.Parameter, err error) {
if sp == nil || sp.Paths == nil {
return nil, nil, nil
}
countsByJSON := map[string]int{}
shared := map[string]spec.Parameter{}
var keys []string
collect := func(p *spec.Parameter) error {
if (p.In == "query" || p.In == "path") && p.Name == "name" {
return nil // ignore name parameter as they are never shared with the Kind in the description
}
if p.In == "query" && p.Name == "fieldValidation" {
return nil // keep fieldValidation parameter unshared because kubectl uses it (until 1.27) to detect server-side field validation support
}
if p.In == "query" && p.Name == "dryRun" {
return nil // keep fieldValidation parameter unshared because kubectl uses it (until 1.26) to detect dry-run support
}
if p.Schema != nil && p.In == "body" && p.Name == "body" && !strings.HasPrefix(p.Schema.Ref.String(), "#/definitions/io.k8s.apimachinery") {
return nil // ignore non-generic body parameters as they reference the custom schema of the kind
}
bs, err := json.Marshal(p)
if err != nil {
return err
}
k := string(bs)
countsByJSON[k]++
if count := countsByJSON[k]; count == 1 {
shared[k] = *p
keys = append(keys, k)
}
return nil
}
for _, path := range sp.Paths.Paths {
// per operation parameters
for _, op := range operations(&path) {
if op == nil {
continue // shouldn't happen, but ignore if it does; tested through unit test
}
for _, p := range op.Parameters {
if p.Ref.String() != "" {
// shouldn't happen, but ignore if it does
continue
}
if err := collect(&p); err != nil {
return nil, nil, err
}
}
}
// per path parameters
for _, p := range path.Parameters {
if p.Ref.String() != "" {
continue // shouldn't happen, but ignore if it does
}
if err := collect(&p); err != nil {
return nil, nil, err
}
}
}
// name deterministically
sort.Strings(keys)
ret = map[string]spec.Parameter{}
namesByJSON = map[string]string{}
for _, k := range keys {
name := shared[k].Name
if name == "" {
// this should never happen as the name is a required field. But if it does, let's be safe.
name = "param"
}
name += "-" + base64Hash(k)
i := 0
for {
if _, ok := ret[name]; !ok {
ret[name] = shared[k]
namesByJSON[k] = name
break
}
i++ // only on hash conflict, unlikely with our few variants
name = shared[k].Name + "-" + strconv.Itoa(i)
}
}
return namesByJSON, ret, nil
}
func operations(path *spec.PathItem) []*spec.Operation {
return []*spec.Operation{path.Get, path.Put, path.Post, path.Delete, path.Options, path.Head, path.Patch}
}
func base64Hash(s string) string {
hash := fnv.New64()
hash.Write([]byte(s)) //nolint:errcheck
return base64.URLEncoding.EncodeToString(hash.Sum(make([]byte, 0, 8))[:6]) // 8 characters
}
func replaceSharedParameters(sharedParameterNamesByJSON map[string]string, sp *spec.Swagger) (*spec.Swagger, error) {
if sp == nil || sp.Paths == nil {
return sp, nil
}
ret := sp
firstPathChange := true
for k, path := range sp.Paths.Paths {
pathChanged := false
// per operation parameters
for _, op := range []**spec.Operation{&path.Get, &path.Put, &path.Post, &path.Delete, &path.Options, &path.Head, &path.Patch} {
if *op == nil {
continue
}
firstParamChange := true
for i := range (*op).Parameters {
p := (*op).Parameters[i]
if p.Ref.String() != "" {
// shouldn't happen, but be idem-potent if it does
continue
}
bs, err := json.Marshal(p)
if err != nil {
return nil, err
}
if name, ok := sharedParameterNamesByJSON[string(bs)]; ok {
if firstParamChange {
orig := *op
*op = &spec.Operation{}
**op = *orig
(*op).Parameters = make([]spec.Parameter, len(orig.Parameters))
copy((*op).Parameters, orig.Parameters)
firstParamChange = false
}
(*op).Parameters[i] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/" + name),
},
}
pathChanged = true
}
}
}
// per path parameters
firstParamChange := true
for i := range path.Parameters {
p := path.Parameters[i]
if p.Ref.String() != "" {
// shouldn't happen, but be idem-potent if it does
continue
}
bs, err := json.Marshal(p)
if err != nil {
return nil, err
}
if name, ok := sharedParameterNamesByJSON[string(bs)]; ok {
if firstParamChange {
orig := path.Parameters
path.Parameters = make([]spec.Parameter, len(orig))
copy(path.Parameters, orig)
firstParamChange = false
}
path.Parameters[i] = spec.Parameter{
Refable: spec.Refable{
Ref: spec.MustCreateRef("#/parameters/" + name),
},
}
pathChanged = true
}
}
if pathChanged {
if firstPathChange {
clone := *sp
ret = &clone
pathsClone := *ret.Paths
ret.Paths = &pathsClone
ret.Paths.Paths = make(map[string]spec.PathItem, len(sp.Paths.Paths))
for k, v := range sp.Paths.Paths {
ret.Paths.Paths[k] = v
}
firstPathChange = false
}
ret.Paths.Paths[k] = path
}
}
return ret, nil
}
================================================
FILE: pkg/builder/parameters_test.go
================================================
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"encoding/json"
"reflect"
"testing"
"github.com/stretchr/testify/require"
"k8s.io/kube-openapi/pkg/validation/spec"
)
func TestCollectSharedParameters(t *testing.T) {
tests := []struct {
name string
spec string
want map[string]string
}{
{
name: "empty",
spec: "",
want: nil,
},
{
name: "no shared",
spec: `{
"parameters": {"pre": {"in": "body", "name": "body", "required": true, "schema": {}}},
"paths": {
"/api/v1/a/{name}": {"get": {"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]}},
"/api/v1/a/{name}/foo": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}": {"get": {"parameters": [
{"description": "x","in":"query","name": "x2","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y2","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}/foo": {"get": {"parameters": [
{"description": "z","in":"query","name": "z2","type":"boolean","uniqueItems":true}
]}}
}
}`,
want: map[string]string{
`{"uniqueItems":true,"type":"boolean","description":"x","name":"x","in":"query"}`: "x-yaDSHpi7",
`{"uniqueItems":true,"type":"boolean","description":"y","name":"y","in":"query"}`: "y-g6h7lEsz",
`{"uniqueItems":true,"type":"boolean","description":"z","name":"z","in":"query"}`: "z--SXYWoM_",
`{"uniqueItems":true,"type":"boolean","description":"x","name":"x2","in":"query"}`: "x2-nds6MpS1",
`{"uniqueItems":true,"type":"boolean","description":"y","name":"y2","in":"query"}`: "y2-exnalzYE",
`{"uniqueItems":true,"type":"boolean","description":"z","name":"z2","in":"query"}`: "z2-8oJfzBQF",
},
},
{
name: "shared per operation",
spec: `{
"parameters": {"pre": {"in": "body", "name": "body", "required": true, "schema": {}}},
"paths": {
"/api/v1/a/{name}": {"get": {"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]}},
"/api/v1/a/{name}/foo": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}/foo": {"get": {"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true}
]}}
}
}`,
want: map[string]string{
`{"uniqueItems":true,"type":"boolean","description":"x","name":"x","in":"query"}`: "x-yaDSHpi7",
`{"uniqueItems":true,"type":"boolean","description":"y","name":"y","in":"query"}`: "y-g6h7lEsz",
`{"uniqueItems":true,"type":"boolean","description":"z","name":"z","in":"query"}`: "z--SXYWoM_",
},
},
{
name: "shared per path",
spec: `{
"parameters": {"pre": {"in": "body", "name": "body", "required": true, "schema": {}}},
"paths": {
"/api/v1/a/{name}": {"get": {},
"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]
},
"/api/v1/a/{name}/foo": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}": {"get": {},
"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true}
]
},
"/api/v1/b/{name}/foo": {"get": {"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true}
]}}
}
}`,
want: map[string]string{
`{"uniqueItems":true,"type":"boolean","description":"x","name":"x","in":"query"}`: "x-yaDSHpi7",
`{"uniqueItems":true,"type":"boolean","description":"y","name":"y","in":"query"}`: "y-g6h7lEsz",
`{"uniqueItems":true,"type":"boolean","description":"z","name":"z","in":"query"}`: "z--SXYWoM_",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var sp *spec.Swagger
if tt.spec != "" {
err := json.Unmarshal([]byte(tt.spec), &sp)
require.NoError(t, err)
}
gotNamesByJSON, _, err := collectSharedParameters(sp)
require.NoError(t, err)
require.Equalf(t, tt.want, gotNamesByJSON, "unexpected shared parameters")
})
}
}
func TestReplaceSharedParameters(t *testing.T) {
shared := map[string]string{
`{"uniqueItems":true,"type":"boolean","description":"x","name":"x","in":"query"}`: "x",
`{"uniqueItems":true,"type":"boolean","description":"y","name":"y","in":"query"}`: "y",
`{"uniqueItems":true,"type":"boolean","description":"z","name":"z","in":"query"}`: "z",
}
tests := []struct {
name string
spec string
want string
}{
{
name: "empty",
spec: "{}",
want: `{"paths":null}`,
},
{
name: "existing parameters",
spec: `{"parameters": {"a":{"type":"boolean"}}}`,
want: `{"parameters": {"a":{"type":"boolean"}},"paths":null}`,
},
{
name: "replace",
spec: `{
"parameters": {"pre": {"in": "body", "name": "body", "required": true, "schema": {}}},
"paths": {
"/api/v1/a/{name}": {"get": {"description":"foo"},
"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]
},
"/api/v1/a/{name}/foo": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true},
{"description": "y","in":"query","name": "y","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}": {"get": {"parameters": [
{"description": "z","in":"query","name": "z","type":"boolean","uniqueItems":true}
]}},
"/api/v1/b/{name}/foo": {"get": {"parameters": [
{"description": "x","in":"query","name": "x","type":"boolean","uniqueItems":true},
{"description": "w","in":"query","name": "w","type":"boolean","uniqueItems":true}
]}}
}
}`,
want: `{
"parameters": {"pre":{"in":"body","name":"body","required":true,"schema":{}}},
"paths": {
"/api/v1/a/{name}": {"get": {"description":"foo"},
"parameters": [
{"$ref": "#/parameters/x"},
{"$ref": "#/parameters/y"}
]
},
"/api/v1/a/{name}/foo": {"get": {"parameters": [
{"$ref": "#/parameters/z"},
{"$ref": "#/parameters/y"}
]}},
"/api/v1/b/{name}": {"get": {"parameters": [
{"$ref": "#/parameters/z"}
]}},
"/api/v1/b/{name}/foo": {"get": {"parameters": [
{"$ref":"#/parameters/x"},
{"description": "w","in":"query","name": "w","type":"boolean","uniqueItems":true}
]}}
}
}`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var unmarshalled *spec.Swagger
err := json.Unmarshal([]byte(tt.spec), &unmarshalled)
require.NoError(t, err)
got, err := replaceSharedParameters(shared, unmarshalled)
require.NoError(t, err)
require.Equalf(t, normalizeJSON(t, tt.want), normalizeJSON(t, toJSON(t, got)), "unexpected result")
})
}
}
func toJSON(t *testing.T, x interface{}) string {
bs, err := json.Marshal(x)
require.NoError(t, err)
return string(bs)
}
func normalizeJSON(t *testing.T, j string) string {
var obj interface{}
err := json.Unmarshal([]byte(j), &obj)
require.NoError(t, err)
return toJSON(t, obj)
}
func TestOperations(t *testing.T) {
t.Log("Ensuring that operations() returns all operations in spec.PathItemProps")
path := spec.PathItem{}
v := reflect.ValueOf(path.PathItemProps)
var rOps []any
for i := 0; i < v.NumField(); i++ {
if v.Field(i).Kind() == reflect.Ptr {
rOps = append(rOps, v.Field(i).Interface())
}
}
ops := operations(&path)
require.Equal(t, len(rOps), len(ops), "operations() should return all operations in spec.PathItemProps")
}
================================================
FILE: pkg/builder/util.go
================================================
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"sort"
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/validation/spec"
)
type parameters []spec.Parameter
func (s parameters) Len() int { return len(s) }
func (s parameters) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// byNameIn used in sorting parameters by Name and In fields.
type byNameIn struct {
parameters
}
func (s byNameIn) Less(i, j int) bool {
return s.parameters[i].Name < s.parameters[j].Name || (s.parameters[i].Name == s.parameters[j].Name && s.parameters[i].In < s.parameters[j].In)
}
// SortParameters sorts parameters by Name and In fields.
func sortParameters(p []spec.Parameter) {
sort.Sort(byNameIn{p})
}
func groupRoutesByPath(routes []common.Route) map[string][]common.Route {
pathToRoutes := make(map[string][]common.Route)
for _, r := range routes {
pathToRoutes[r.Path()] = append(pathToRoutes[r.Path()], r)
}
return pathToRoutes
}
func mapKeyFromParam(param common.Parameter) interface{} {
return struct {
Name string
Kind common.ParameterKind
}{
Name: param.Name(),
Kind: param.Kind(),
}
}
================================================
FILE: pkg/builder3/openapi.go
================================================
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder3
import (
"encoding/json"
"fmt"
"net/http"
"strings"
restful "github.com/emicklei/go-restful/v3"
builderutil "k8s.io/kube-openapi/pkg/builder3/util"
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/common/restfuladapter"
"k8s.io/kube-openapi/pkg/spec3"
"k8s.io/kube-openapi/pkg/util"
"k8s.io/kube-openapi/pkg/validation/spec"
)
const (
OpenAPIVersion = "3.0"
)
type openAPI struct {
config *common.OpenAPIV3Config
spec *spec3.OpenAPI
definitions map[string]common.OpenAPIDefinition
}
func groupRoutesByPath(routes []common.Route) map[string][]common.Route {
pathToRoutes := make(map[string][]common.Route)
for _, r := range routes {
pathToRoutes[r.Path()] = append(pathToRoutes[r.Path()], r)
}
return pathToRoutes
}
func (o *openAPI) buildResponse(model interface{}, description string, content []string) (*spec3.Response, error) {
response := &spec3.Response{
ResponseProps: spec3.ResponseProps{
Description: description,
Content: make(map[string]*spec3.MediaType),
},
}
s, err := o.toSchema(util.GetCanonicalTypeName(model))
if err != nil {
return nil, err
}
for _, contentType := range content {
response.ResponseProps.Content[contentType] = &spec3.MediaType{
MediaTypeProps: spec3.MediaTypeProps{
Schema: s,
},
}
}
return response, nil
}
func (o *openAPI) buildOperations(route common.Route, inPathCommonParamsMap map[interface{}]*spec3.Parameter) (*spec3.Operation, error) {
ret := &spec3.Operation{
OperationProps: spec3.OperationProps{
Description: route.Description(),
Responses: &spec3.Responses{
ResponsesProps: spec3.ResponsesProps{
StatusCodeResponses: make(map[int]*spec3.Response),
},
},
},
}
for k, v := range route.Metadata() {
if strings.HasPrefix(k, common.ExtensionPrefix) {
if ret.Extensions == nil {
ret.Extensions = spec.Extensions{}
}
ret.Extensions.Add(k, v)
}
}
var err error
if ret.OperationId, ret.Tags, err = o.config.GetOperationIDAndTagsFromRoute(route); err != nil {
return ret, err
}
// Build responses
for _, resp := range route.StatusCodeResponses() {
ret.Responses.StatusCodeResponses[resp.Code()], err = o.buildResponse(resp.Model(), resp.Message(), route.Produces())
if err != nil {
return ret, err
}
}
// If there is no response but a write sample, assume that write sample is an http.StatusOK response.
if len(ret.Responses.StatusCodeResponses) == 0 && route.ResponsePayloadSample() != nil {
ret.Responses.StatusCodeResponses[http.StatusOK], err = o.buildResponse(route.ResponsePayloadSample(), "OK", route.Produces())
if err != nil {
return ret, err
}
}
for code, resp := range o.config.CommonResponses {
if _, exists := ret.Responses.StatusCodeResponses[code]; !exists {
ret.Responses.StatusCodeResponses[code] = resp
}
}
if len(ret.Responses.StatusCodeResponses) == 0 {
ret.Responses.Default = o.config.DefaultResponse
}
params := route.Parameters()
for _, param := range params {
_, isCommon := inPathCommonParamsMap[mapKeyFromParam(param)]
if !isCommon && param.Kind() != common.BodyParameterKind {
openAPIParam, err := o.buildParameter(param)
if err != nil {
return ret, err
}
ret.Parameters = append(ret.Parameters, openAPIParam)
}
}
body, err := o.buildRequestBody(params, route.Consumes(), route.RequestPayloadSample())
if err != nil {
return nil, err
}
if body != nil {
ret.RequestBody = body
}
return ret, nil
}
func (o *openAPI) buildRequestBody(parameters []common.Parameter, consumes []string, bodySample interface{}) (*spec3.RequestBody, error) {
for _, param := range parameters {
if param.Kind() == common.BodyParameterKind && bodySample != nil {
schema, err := o.toSchema(util.GetCanonicalTypeName(bodySample))
if err != nil {
return nil, err
}
r := &spec3.RequestBody{
RequestBodyProps: spec3.RequestBodyProps{
Content: map[string]*spec3.MediaType{},
Description: param.Description(),
Required: param.Required(),
},
}
for _, consume := range consumes {
r.Content[consume] = &spec3.MediaType{
MediaTypeProps: spec3.MediaTypeProps{
Schema: schema,
},
}
}
return r, nil
}
}
return nil, nil
}
func newOpenAPI(config *common.OpenAPIV3Config) openAPI {
o := openAPI{
config: config,
spec: &spec3.OpenAPI{
Version: "3.0.0",
Info: config.Info,
Paths: &spec3.Paths{
Paths: map[string]*spec3.Path{},
},
Components: &spec3.Components{
Schemas: map[string]*spec.Schema{},
},
},
}
if len(o.config.ResponseDefinitions) > 0 {
o.spec.Components.Responses = make(map[string]*spec3.Response)
}
for k, response := range o.config.ResponseDefinitions {
o.spec.Components.Responses[k] = response
}
if len(o.config.SecuritySchemes) > 0 {
o.spec.Components.SecuritySchemes = make(spec3.SecuritySchemes)
}
for k, securityScheme := range o.config.SecuritySchemes {
o.spec.Components.SecuritySchemes[k] = securityScheme
}
if o.config.GetOperationIDAndTagsFromRoute == nil {
// Map the deprecated handler to the common interface, if provided.
if o.config.GetOperationIDAndTags != nil {
o.config.GetOperationIDAndTagsFromRoute = func(r common.Route) (string, []string, error) {
restfulRouteAdapter, ok := r.(*restfuladapter.RouteAdapter)
if !ok {
return "", nil, fmt.Errorf("config.GetOperationIDAndTags specified but route is not a restful v1 Route")
}
return o.config.GetOperationIDAndTags(restfulRouteAdapter.Route)
}
} else {
o.config.GetOperationIDAndTagsFromRoute = func(r common.Route) (string, []string, error) {
return r.OperationName(), nil, nil
}
}
}
if o.config.GetDefinitionName == nil {
o.config.GetDefinitionName = func(name string) (string, spec.Extensions) {
return name[strings.LastIndex(name, "/")+1:], nil
}
}
if o.config.Definitions != nil {
o.definitions = o.config.Definitions
} else {
o.definitions = o.config.GetDefinitions(func(name string) spec.Ref {
defName, _ := o.config.GetDefinitionName(name)
return spec.MustCreateRef("#/components/schemas/" + common.EscapeJsonPointer(defName))
})
}
return o
}
func (o *openAPI) buildOpenAPISpec(webServices []common.RouteContainer) error {
pathsToIgnore := util.NewTrie(o.config.IgnorePrefixes)
for _, w := range webServices {
rootPath := w.RootPath()
if pathsToIgnore.HasPrefix(rootPath) {
continue
}
commonParams, err := o.buildParameters(w.PathParameters())
if err != nil {
return err
}
for path, routes := range groupRoutesByPath(w.Routes()) {
// go-swagger has special variable definition {$NAME:*} that can only be
// used at the end of the path and it is not recognized by OpenAPI.
if strings.HasSuffix(path, ":*}") {
path = path[:len(path)-3] + "}"
}
if pathsToIgnore.HasPrefix(path) {
continue
}
// Aggregating common parameters make API spec (and generated clients) simpler
inPathCommonParamsMap, err := o.findCommonParameters(routes)
if err != nil {
return err
}
pathItem, exists := o.spec.Paths.Paths[path]
if exists {
return fmt.Errorf("duplicate webservice route has been found for path: %v", path)
}
pathItem = &spec3.Path{
PathProps: spec3.PathProps{},
}
// add web services's parameters as well as any parameters appears in all ops, as common parameters
pathItem.Parameters = append(pathItem.Parameters, commonParams...)
for _, p := range inPathCommonParamsMap {
pathItem.Parameters = append(pathItem.Parameters, p)
}
sortParameters(pathItem.Parameters)
for _, route := range routes {
op, err := o.buildOperations(route, inPathCommonParamsMap)
if err != nil {
return err
}
sortParameters(op.Parameters)
switch strings.ToUpper(route.Method()) {
case "GET":
pathItem.Get = op
case "POST":
pathItem.Post = op
case "HEAD":
pathItem.Head = op
case "PUT":
pathItem.Put = op
case "DELETE":
pathItem.Delete = op
case "OPTIONS":
pathItem.Options = op
case "PATCH":
pathItem.Patch = op
}
}
o.spec.Paths.Paths[path] = pathItem
}
}
return nil
}
// BuildOpenAPISpec builds OpenAPI v3 spec given a list of route containers and common.Config to customize it.
//
// Deprecated: BuildOpenAPISpecFromRoutes should be used instead.
func BuildOpenAPISpec(webServices []*restful.WebService, config *common.OpenAPIV3Config) (*spec3.OpenAPI, error) {
return BuildOpenAPISpecFromRoutes(restfuladapter.AdaptWebServices(webServices), config)
}
// BuildOpenAPISpecFromRoutes builds OpenAPI v3 spec given a list of route containers and common.Config to customize it.
func BuildOpenAPISpecFromRoutes(webServices []common.RouteContainer, config *common.OpenAPIV3Config) (*spec3.OpenAPI, error) {
a := newOpenAPI(config)
err := a.buildOpenAPISpec(webServices)
if err != nil {
return nil, err
}
if config.PostProcessSpec != nil {
return config.PostProcessSpec(a.spec)
}
return a.spec, nil
}
// BuildOpenAPIDefinitionsForResource builds a partial OpenAPI spec given a sample object and common.Config to customize it.
// BuildOpenAPIDefinitionsForResources returns the OpenAPI spec which includes the definitions for the
// passed type names.
func BuildOpenAPIDefinitionsForResources(config *common.OpenAPIV3Config, names ...string) (map[string]*spec.Schema, error) {
o := newOpenAPI(config)
// We can discard the return value of toSchema because all we care about is the side effect of calling it.
// All the models created for this resource get added to o.swagger.Definitions
for _, name := range names {
_, err := o.toSchema(name)
if err != nil {
return nil, err
}
}
return o.spec.Components.Schemas, nil
}
func (o *openAPI) findCommonParameters(routes []common.Route) (map[interface{}]*spec3.Parameter, error) {
commonParamsMap := make(map[interface{}]*spec3.Parameter, 0)
paramOpsCountByName := make(map[interface{}]int, 0)
paramNameKindToDataMap := make(map[interface{}]common.Parameter, 0)
for _, route := range routes {
routeParamDuplicateMap := make(map[interface{}]bool)
s := ""
params := route.Parameters()
for _, param := range params {
m, _ := json.Marshal(param)
s += string(m) + "\n"
key := mapKeyFromParam(param)
if routeParamDuplicateMap[key] {
msg, _ := json.Marshal(params)
return commonParamsMap, fmt.Errorf("duplicate parameter %v for route %v, %v", param.Name(), string(msg), s)
}
routeParamDuplicateMap[key] = true
paramOpsCountByName[key]++
paramNameKindToDataMap[key] = param
}
}
for key, count := range paramOpsCountByName {
paramData := paramNameKindToDataMap[key]
if count == len(routes) && paramData.Kind() != common.BodyParameterKind {
openAPIParam, err := o.buildParameter(paramData)
if err != nil {
return commonParamsMap, err
}
commonParamsMap[key] = openAPIParam
}
}
return commonParamsMap, nil
}
func (o *openAPI) buildParameters(restParam []common.Parameter) (ret []*spec3.Parameter, err error) {
ret = make([]*spec3.Parameter, len(restParam))
for i, v := range restParam {
ret[i], err = o.buildParameter(v)
if err != nil {
return ret, err
}
}
return ret, nil
}
func (o *openAPI) buildParameter(restParam common.Parameter) (ret *spec3.Parameter, err error) {
ret = &spec3.Parameter{
ParameterProps: spec3.ParameterProps{
Name: restParam.Name(),
Description: restParam.Description(),
Required: restParam.Required(),
},
}
switch restParam.Kind() {
case common.BodyParameterKind:
return nil, nil
case common.PathParameterKind:
ret.In = "path"
if !restParam.Required() {
return ret, fmt.Errorf("path parameters should be marked as required for parameter %v", restParam)
}
case common.QueryParameterKind:
ret.In = "query"
case common.HeaderParameterKind:
ret.In = "header"
/* TODO: add support for the cookie param */
default:
return ret, fmt.Errorf("unsupported restful parameter kind : %v", restParam.Kind())
}
openAPIType, openAPIFormat := common.OpenAPITypeFormat(restParam.DataType())
if openAPIType == "" {
return ret, fmt.Errorf("non-body Restful parameter type should be a simple type, but got : %v", restParam.DataType())
}
ret.Schema = &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{openAPIType},
Format: openAPIFormat,
UniqueItems: !restParam.AllowMultiple(),
},
}
return ret, nil
}
func (o *openAPI) buildDefinitionRecursively(name string) error {
uniqueName, extensions := o.config.GetDefinitionName(name)
escapedName := common.EscapeJsonPointer(uniqueName)
if _, ok := o.spec.Components.Schemas[escapedName]; ok {
return nil
}
if item, ok := o.definitions[name]; ok {
schema := &spec.Schema{
VendorExtensible: item.Schema.VendorExtensible,
SchemaProps: item.Schema.SchemaProps,
SwaggerSchemaProps: item.Schema.SwaggerSchemaProps,
}
if extensions != nil {
if schema.Extensions == nil {
schema.Extensions = spec.Extensions{}
}
for k, v := range extensions {
schema.Extensions[k] = v
}
}
// delete the embedded v2 schema if exists, otherwise no-op
delete(schema.VendorExtensible.Extensions, common.ExtensionV2Schema)
schema = builderutil.WrapRefs(schema)
o.spec.Components.Schemas[escapedName] = schema
for _, v := range item.Dependencies {
if err := o.buildDefinitionRecursively(v); err != nil {
return err
}
}
} else {
return fmt.Errorf("cannot find model definition for %v. If you added a new type, you may need to add +k8s:openapi-gen=true to the package or type and run code-gen again", name)
}
return nil
}
func (o *openAPI) buildDefinitionForType(name string) (string, error) {
if err := o.buildDefinitionRecursively(name); err != nil {
return "", err
}
defName, _ := o.config.GetDefinitionName(name)
return "#/components/schemas/" + common.EscapeJsonPointer(defName), nil
}
func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) {
if openAPIType, openAPIFormat := common.OpenAPITypeFormat(name); openAPIType != "" {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{openAPIType},
Format: openAPIFormat,
},
}, nil
} else {
ref, err := o.buildDefinitionForType(name)
if err != nil {
return nil, err
}
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef(ref),
},
}, nil
}
}
================================================
FILE: pkg/builder3/openapi_test.go
================================================
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder3
import (
"encoding/json"
"fmt"
"net/http"
"strings"
"testing"
"github.com/emicklei/go-restful/v3"
"github.com/stretchr/testify/assert"
openapi "k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/spec3"
"k8s.io/kube-openapi/pkg/util/jsontesting"
"k8s.io/kube-openapi/pkg/validation/spec"
)
// setUp is a convenience function for setting up for (most) tests.
func setUp(t *testing.T, fullMethods bool) (*openapi.OpenAPIV3Config, *restful.Container, *assert.Assertions) {
assert := assert.New(t)
config, container := getConfig(fullMethods)
return config, container, assert
}
func noOp(request *restful.Request, response *restful.Response) {}
// Test input
type TestInput struct {
// Name of the input
Name string `json:"name,omitempty"`
// ID of the input
ID int `json:"id,omitempty"`
Tags []string `json:"tags,omitempty"`
}
// Test output
type TestOutput struct {
// Name of the output
Name string `json:"name,omitempty"`
// Number of outputs
Count int `json:"count,omitempty"`
}
func (_ TestInput) OpenAPIDefinition() openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test input"
schema.Properties = map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the input",
Type: []string{"string"},
Format: "",
},
},
"id": {
SchemaProps: spec.SchemaProps{
Description: "ID of the input",
Type: []string{"integer"},
Format: "int32",
},
},
"tags": {
SchemaProps: spec.SchemaProps{
Description: "",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
"reference-extension": {
VendorExtensible: spec.VendorExtensible{
Extensions: map[string]interface{}{"extension": "value"},
},
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
},
},
"reference-nullable": {
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
Nullable: true,
},
},
"reference-default": {
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
Default: map[string]interface{}{},
},
},
}
schema.Extensions = spec.Extensions{"x-test": "test"}
def := openapi.EmbedOpenAPIDefinitionIntoV2Extension(openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{},
}, openapi.OpenAPIDefinition{
// this empty embedded v2 definition should not appear in the result
})
return def
}
func (_ TestOutput) OpenAPIDefinition() openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test output"
schema.Properties = map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the output",
Type: []string{"string"},
Format: "",
},
},
"count": {
SchemaProps: spec.SchemaProps{
Description: "Number of outputs",
Type: []string{"integer"},
Format: "int32",
},
},
}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{},
}
}
var _ openapi.OpenAPIDefinitionGetter = TestInput{}
var _ openapi.OpenAPIDefinitionGetter = TestOutput{}
func getTestRoute(ws *restful.WebService, method string, opPrefix string) *restful.RouteBuilder {
ret := ws.Method(method).
Path("/test/{path:*}").
Doc(fmt.Sprintf("%s test input", method)).
Operation(fmt.Sprintf("%s%sTestInput", method, opPrefix)).
Produces(restful.MIME_JSON).
Consumes(restful.MIME_JSON).
Param(ws.PathParameter("path", "path to the resource").DataType("string")).
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
Reads(TestInput{}).
Returns(200, "OK", TestOutput{}).
Writes(TestOutput{}).
To(noOp)
return ret
}
func getConfig(fullMethods bool) (*openapi.OpenAPIV3Config, *restful.Container) {
mux := http.NewServeMux()
container := restful.NewContainer()
container.ServeMux = mux
ws := new(restful.WebService)
ws.Path("/foo")
ws.Route(getTestRoute(ws, "get", "foo"))
if fullMethods {
ws.Route(getTestRoute(ws, "post", "foo")).
Route(getTestRoute(ws, "put", "foo")).
Route(getTestRoute(ws, "head", "foo")).
Route(getTestRoute(ws, "patch", "foo")).
Route(getTestRoute(ws, "options", "foo")).
Route(getTestRoute(ws, "delete", "foo"))
}
ws.Path("/bar")
ws.Route(getTestRoute(ws, "get", "bar"))
if fullMethods {
ws.Route(getTestRoute(ws, "post", "bar")).
Route(getTestRoute(ws, "put", "bar")).
Route(getTestRoute(ws, "head", "bar")).
Route(getTestRoute(ws, "patch", "bar")).
Route(getTestRoute(ws, "options", "bar")).
Route(getTestRoute(ws, "delete", "bar"))
}
container.Add(ws)
return &openapi.OpenAPIV3Config{
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "unversioned",
},
},
GetDefinitions: func(_ openapi.ReferenceCallback) map[string]openapi.OpenAPIDefinition {
return map[string]openapi.OpenAPIDefinition{
"k8s.io/kube-openapi/pkg/builder3.TestInput": TestInput{}.OpenAPIDefinition(),
"k8s.io/kube-openapi/pkg/builder3.TestOutput": TestOutput{}.OpenAPIDefinition(),
}
},
GetDefinitionName: func(name string) (string, spec.Extensions) {
friendlyName := name[strings.LastIndex(name, "/")+1:]
return friendlyName, spec.Extensions{"x-test2": "test2"}
},
}, container
}
func getTestOperation(method string, opPrefix string) *spec3.Operation {
return &spec3.Operation{
OperationProps: spec3.OperationProps{
Description: fmt.Sprintf("%s test input", method),
Parameters: []*spec3.Parameter{},
Responses: getTestResponses(),
OperationId: fmt.Sprintf("%s%sTestInput", method, opPrefix),
},
}
}
func getTestPathItem(opPrefix string) *spec3.Path {
ret := &spec3.Path{
PathProps: spec3.PathProps{
Get: getTestOperation("get", opPrefix),
Parameters: getTestCommonParameters(),
},
}
ret.Get.RequestBody = getTestRequestBody()
ret.Put = getTestOperation("put", opPrefix)
ret.Put.RequestBody = getTestRequestBody()
ret.Post = getTestOperation("post", opPrefix)
ret.Post.RequestBody = getTestRequestBody()
ret.Head = getTestOperation("head", opPrefix)
ret.Head.RequestBody = getTestRequestBody()
ret.Patch = getTestOperation("patch", opPrefix)
ret.Patch.RequestBody = getTestRequestBody()
ret.Delete = getTestOperation("delete", opPrefix)
ret.Delete.RequestBody = getTestRequestBody()
ret.Options = getTestOperation("options", opPrefix)
ret.Options.RequestBody = getTestRequestBody()
return ret
}
func getRefSchema(ref string) *spec.Schema {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef(ref),
},
}
}
func getTestResponses() *spec3.Responses {
ret := &spec3.Responses{
ResponsesProps: spec3.ResponsesProps{
StatusCodeResponses: map[int]*spec3.Response{},
},
}
ret.StatusCodeResponses[200] = &spec3.Response{
ResponseProps: spec3.ResponseProps{
Description: "OK",
Content: map[string]*spec3.MediaType{},
},
}
ret.StatusCodeResponses[200].Content[restful.MIME_JSON] = &spec3.MediaType{
MediaTypeProps: spec3.MediaTypeProps{
Schema: getRefSchema("#/components/schemas/builder3.TestOutput"),
},
}
return ret
}
func getTestCommonParameters() []*spec3.Parameter {
ret := make([]*spec3.Parameter, 2)
ret[0] = &spec3.Parameter{
ParameterProps: spec3.ParameterProps{
Description: "path to the resource",
Name: "path",
In: "path",
Required: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
UniqueItems: true,
},
},
},
}
ret[1] = &spec3.Parameter{
ParameterProps: spec3.ParameterProps{
Description: "If 'true', then the output is pretty printed.",
Name: "pretty",
In: "query",
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
UniqueItems: true,
},
},
},
}
return ret
}
func getTestRequestBody() *spec3.RequestBody {
ret := &spec3.RequestBody{
RequestBodyProps: spec3.RequestBodyProps{
Content: map[string]*spec3.MediaType{
restful.MIME_JSON: {
MediaTypeProps: spec3.MediaTypeProps{
Schema: getRefSchema("#/components/schemas/builder3.TestInput"),
},
},
},
Required: true,
},
}
return ret
}
func getTestInputDefinition() *spec.Schema {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Test input",
Properties: map[string]spec.Schema{
"id": {
SchemaProps: spec.SchemaProps{
Description: "ID of the input",
Type: spec.StringOrArray{"integer"},
Format: "int32",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the input",
Type: spec.StringOrArray{"string"},
},
},
"tags": {
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: spec.StringOrArray{"string"},
},
},
},
},
},
"reference-extension": {
VendorExtensible: spec.VendorExtensible{
Extensions: map[string]interface{}{"extension": "value"},
},
SchemaProps: spec.SchemaProps{
AllOf: []spec.Schema{{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
},
}},
},
},
"reference-nullable": {
SchemaProps: spec.SchemaProps{
Nullable: true,
AllOf: []spec.Schema{{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
},
}},
},
},
"reference-default": {
SchemaProps: spec.SchemaProps{
AllOf: []spec.Schema{{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("/components/schemas/builder3.TestOutput"),
},
}},
Default: map[string]interface{}{},
},
},
},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-test": "test",
"x-test2": "test2",
},
},
}
}
func getTestOutputDefinition() *spec.Schema {
return &spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Test output",
Properties: map[string]spec.Schema{
"count": {
SchemaProps: spec.SchemaProps{
Description: "Number of outputs",
Type: spec.StringOrArray{"integer"},
Format: "int32",
},
},
"name": {
SchemaProps: spec.SchemaProps{
Description: "Name of the output",
Type: spec.StringOrArray{"string"},
},
},
},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-test2": "test2",
},
},
}
}
func TestBuildOpenAPISpec(t *testing.T) {
config, container, assert := setUp(t, true)
expected := &spec3.OpenAPI{
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "unversioned",
},
VendorExtensible: spec.VendorExtensible{
Extensions: map[string]any{
"hello": "world", // set from PostProcessSpec callback
},
},
},
Version: "3.0.0",
Paths: &spec3.Paths{
Paths: map[string]*spec3.Path{
"/foo/test/{path}": getTestPathItem("foo"),
"/bar/test/{path}": getTestPathItem("bar"),
},
},
Components: &spec3.Components{
Schemas: map[string]*spec.Schema{
"builder3.TestInput": getTestInputDefinition(),
"builder3.TestOutput": getTestOutputDefinition(),
},
},
}
config.PostProcessSpec = func(s *spec3.OpenAPI) (*spec3.OpenAPI, error) {
s.Info.Extensions = map[string]any{
"hello": "world",
}
return s, nil
}
swagger, err := BuildOpenAPISpec(container.RegisteredWebServices(), config)
if !assert.NoError(err) {
return
}
expected_json, err := json.Marshal(expected)
if !assert.NoError(err) {
return
}
actual_json, err := json.Marshal(swagger)
if !assert.NoError(err) {
return
}
if err := jsontesting.JsonCompare(expected_json, actual_json); err != nil {
t.Error(err)
}
}
type TestRecursiveType struct {
Value string `json:"value,omitempty"`
Children []TestRecursiveType `json:"children,omitempty"`
}
func makeRecursiveTypeDefinition(depName string) openapi.OpenAPIDefinition {
schema := spec.Schema{}
schema.Description = "Test recursive type for JSON pointer escaping"
schema.Properties = map[string]spec.Schema{
"value": {
SchemaProps: spec.SchemaProps{
Description: "A test value",
Type: []string{"string"},
},
},
"children": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: spec.MustCreateRef("#/components/schemas/" + depName),
},
},
},
},
},
}
return openapi.OpenAPIDefinition{
Schema: schema,
Dependencies: []string{depName},
}
}
func TestEscapeJsonPointerInSchemaName(t *testing.T) {
testCases := []struct {
name string
definitionName string
expectedName string
shouldNotExist string
}{
{
name: "both slash and tilde",
definitionName: "io.k8s/api~v1.TestRecursiveType",
expectedName: "io.k8s~1api~0v1.TestRecursiveType",
shouldNotExist: "io.k8s/api~v1.TestRecursiveType",
},
{
name: "only slashes",
definitionName: "io.k8s/api/v1.TestRecursiveType",
expectedName: "io.k8s~1api~1v1.TestRecursiveType",
shouldNotExist: "io.k8s/api/v1.TestRecursiveType",
},
{
name: "only tildes",
definitionName: "io.k8s~api~v1.TestRecursiveType",
expectedName: "io.k8s~0api~0v1.TestRecursiveType",
shouldNotExist: "io.k8s~api~v1.TestRecursiveType",
},
{
name: "no special characters",
definitionName: "io.k8s.api.v1.TestRecursiveType",
expectedName: "io.k8s.api.v1.TestRecursiveType",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
config := &openapi.OpenAPIV3Config{
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TestAPI",
Description: "Test API",
Version: "v1",
},
},
GetDefinitions: func(_ openapi.ReferenceCallback) map[string]openapi.OpenAPIDefinition {
return map[string]openapi.OpenAPIDefinition{
tc.definitionName: makeRecursiveTypeDefinition(tc.definitionName),
}
},
GetDefinitionName: func(name string) (string, spec.Extensions) {
return name, nil
},
}
schemas, err := BuildOpenAPIDefinitionsForResources(config, tc.definitionName)
assert.NoError(err)
assert.NotNil(schemas)
_, exists := schemas[tc.expectedName]
assert.True(exists, "Schema should exist with escaped name: %s", tc.expectedName)
if tc.shouldNotExist != "" {
_, exists = schemas[tc.shouldNotExist]
assert.False(exists, "Schema should not exist with unescaped name: %s", tc.shouldNotExist)
}
})
}
}
================================================
FILE: pkg/builder3/util/util.go
================================================
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
import (
"reflect"
"k8s.io/kube-openapi/pkg/schemamutation"
"k8s.io/kube-openapi/pkg/validation/spec"
)
// wrapRefs wraps OpenAPI V3 Schema refs that contain sibling elements.
// AllOf is used to wrap the Ref to prevent references from having sibling elements
// Please see https://github.com/kubernetes/kubernetes/issues/106387#issuecomment-967640388
func WrapRefs(schema *spec.Schem
gitextract_j6tmyxjf/
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── OWNERS
├── README.md
├── SECURITY.md
├── SECURITY_CONTACTS
├── boilerplate/
│ └── boilerplate.go.txt
├── cmd/
│ ├── openapi-gen/
│ │ ├── args/
│ │ │ └── args.go
│ │ └── openapi-gen.go
│ └── openapi2smd/
│ └── openapi2smd.go
├── code-of-conduct.md
├── go.mod
├── go.sum
├── hack/
│ ├── JSON-EXPERIMENTAL-HASH
│ ├── update-json-library.sh
│ └── verify-go-directive.sh
├── pkg/
│ ├── aggregator/
│ │ ├── aggregator.go
│ │ ├── aggregator_test.go
│ │ └── walker.go
│ ├── builder/
│ │ ├── doc.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── parameters.go
│ │ ├── parameters_test.go
│ │ └── util.go
│ ├── builder3/
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── util/
│ │ │ └── util.go
│ │ └── util.go
│ ├── cached/
│ │ ├── cache.go
│ │ └── cache_test.go
│ ├── common/
│ │ ├── common.go
│ │ ├── doc.go
│ │ ├── interfaces.go
│ │ └── restfuladapter/
│ │ ├── adapter.go
│ │ ├── param_adapter.go
│ │ ├── response_error_adapter.go
│ │ ├── route_adapter.go
│ │ └── webservice_adapter.go
│ ├── generators/
│ │ ├── README.md
│ │ ├── api_linter.go
│ │ ├── config.go
│ │ ├── config_test.go
│ │ ├── enum.go
│ │ ├── enum_test.go
│ │ ├── extension.go
│ │ ├── extension_test.go
│ │ ├── markers.go
│ │ ├── markers_test.go
│ │ ├── model_names.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── rules/
│ │ │ ├── OWNERS
│ │ │ ├── doc.go
│ │ │ ├── idl_tag.go
│ │ │ ├── idl_tag_test.go
│ │ │ ├── list_type_streaming_tags.go
│ │ │ ├── list_type_streaming_tags_test.go
│ │ │ ├── names_match.go
│ │ │ ├── names_match_test.go
│ │ │ ├── omitempty_match_case.go
│ │ │ └── omitempty_match_case_test.go
│ │ └── union.go
│ ├── handler/
│ │ ├── default_pruning.go
│ │ ├── default_pruning_test.go
│ │ ├── handler.go
│ │ └── handler_test.go
│ ├── handler3/
│ │ ├── handler.go
│ │ └── handler_test.go
│ ├── idl/
│ │ ├── doc.go
│ │ ├── listtype_test.go
│ │ ├── maptype_test.go
│ │ └── structtype_test.go
│ ├── internal/
│ │ ├── flags.go
│ │ ├── serialization.go
│ │ ├── serialization_test.go
│ │ └── third_party/
│ │ ├── go-json-experiment/
│ │ │ ├── README.md
│ │ │ └── json/
│ │ │ ├── AUTHORS
│ │ │ ├── CONTRIBUTORS
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── arshal.go
│ │ │ ├── arshal_any.go
│ │ │ ├── arshal_default.go
│ │ │ ├── arshal_funcs.go
│ │ │ ├── arshal_inlined.go
│ │ │ ├── arshal_methods.go
│ │ │ ├── arshal_test.go
│ │ │ ├── arshal_time.go
│ │ │ ├── bench_test.go
│ │ │ ├── coder_test.go
│ │ │ ├── decode.go
│ │ │ ├── decode_test.go
│ │ │ ├── diff_test.go
│ │ │ ├── doc.go
│ │ │ ├── encode.go
│ │ │ ├── encode_test.go
│ │ │ ├── errors.go
│ │ │ ├── errors_test.go
│ │ │ ├── example_orderedobject_test.go
│ │ │ ├── example_test.go
│ │ │ ├── fields.go
│ │ │ ├── fields_test.go
│ │ │ ├── fold.go
│ │ │ ├── fold_test.go
│ │ │ ├── fuzz_test.go
│ │ │ ├── inline_test.go
│ │ │ ├── intern.go
│ │ │ ├── intern_test.go
│ │ │ ├── pools.go
│ │ │ ├── state.go
│ │ │ ├── state_test.go
│ │ │ ├── testdata_test.go
│ │ │ ├── token.go
│ │ │ ├── token_test.go
│ │ │ ├── value.go
│ │ │ └── value_test.go
│ │ └── govalidator/
│ │ ├── LICENSE
│ │ ├── patterns.go
│ │ ├── validator.go
│ │ └── validator_test.go
│ ├── openapiconv/
│ │ ├── convert.go
│ │ ├── convert_test.go
│ │ └── testdata_generated_from_k8s/
│ │ ├── README.md
│ │ ├── v2_api.v1.json
│ │ ├── v2_apiextensions.k8s.io.v1.json
│ │ ├── v2_batch.v1.json
│ │ ├── v3_api.v1.json
│ │ ├── v3_apiextensions.k8s.io.v1.json
│ │ └── v3_batch.v1.json
│ ├── schemaconv/
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── proto_models.go
│ │ ├── smd.go
│ │ ├── smd_test.go
│ │ └── testdata/
│ │ ├── atomic-types.json
│ │ ├── atomic-types.yaml
│ │ ├── crds/
│ │ │ ├── openapiv2/
│ │ │ │ ├── accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json
│ │ │ │ ├── container_v1beta1_containercluster.json
│ │ │ │ ├── dataproc_v1beta1_dataprocworkflowtemplate.json
│ │ │ │ ├── dlp_v1beta1_dlpdeidentifytemplate.json
│ │ │ │ ├── monitoring_v1beta1_monitoringalertpolicy.json
│ │ │ │ ├── monitoring_v1beta1_monitoringdashboard.json
│ │ │ │ ├── privateca_v1beta1_privatecacertificate.json
│ │ │ │ ├── privateca_v1beta1_privatecacertificateauthority.json
│ │ │ │ ├── storagetransfer_v1beta1_storagetransferjob.json
│ │ │ │ └── vpcaccess_v1beta1_vpcaccessconnector.json
│ │ │ └── openapiv3/
│ │ │ ├── accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json
│ │ │ ├── container_v1beta1_containercluster.json
│ │ │ ├── dataproc_v1beta1_dataprocworkflowtemplate.json
│ │ │ ├── dlp_v1beta1_dlpdeidentifytemplate.json
│ │ │ ├── monitoring_v1beta1_monitoringalertpolicy.json
│ │ │ ├── monitoring_v1beta1_monitoringdashboard.json
│ │ │ ├── privateca_v1beta1_privatecacertificate.json
│ │ │ ├── privateca_v1beta1_privatecacertificateauthority.json
│ │ │ ├── storagetransfer_v1beta1_storagetransferjob.json
│ │ │ └── vpcaccess_v1beta1_vpcaccessconnector.json
│ │ ├── defaults.json
│ │ ├── defaults.yaml
│ │ ├── field-level-annotation.json
│ │ ├── new-schema.yaml
│ │ ├── preserve-unknown.json
│ │ ├── preserve-unknown.yaml
│ │ └── swagger.json
│ ├── schemamutation/
│ │ ├── walker.go
│ │ └── walker_test.go
│ ├── spec3/
│ │ ├── benchmark_serialization_test.go
│ │ ├── component.go
│ │ ├── component_test.go
│ │ ├── encoding.go
│ │ ├── encoding_test.go
│ │ ├── example.go
│ │ ├── example_test.go
│ │ ├── external_documentation.go
│ │ ├── external_documentation_test.go
│ │ ├── fuzz.go
│ │ ├── header.go
│ │ ├── header_test.go
│ │ ├── media_type.go
│ │ ├── media_type_test.go
│ │ ├── operation.go
│ │ ├── operation_test.go
│ │ ├── parameter.go
│ │ ├── parameter_test.go
│ │ ├── path.go
│ │ ├── path_test.go
│ │ ├── request_body.go
│ │ ├── request_body_test.go
│ │ ├── response.go
│ │ ├── response_test.go
│ │ ├── security_scheme.go
│ │ ├── security_scheme_test.go
│ │ ├── server.go
│ │ ├── server_test.go
│ │ ├── spec.go
│ │ └── testdata/
│ │ ├── appsv1spec.json
│ │ └── authorizationv1spec.json
│ ├── util/
│ │ ├── jsontesting/
│ │ │ └── json_roundtrip.go
│ │ ├── proto/
│ │ │ ├── OWNERS
│ │ │ ├── doc.go
│ │ │ ├── document.go
│ │ │ ├── document_v3.go
│ │ │ ├── openapi.go
│ │ │ ├── openapi_test.go
│ │ │ ├── testdata/
│ │ │ │ ├── openapi_v3_0_0/
│ │ │ │ │ ├── apiextensions.k8s.io/
│ │ │ │ │ │ └── v1.json
│ │ │ │ │ ├── apps/
│ │ │ │ │ │ └── v1.json
│ │ │ │ │ ├── batch/
│ │ │ │ │ │ ├── v1.json
│ │ │ │ │ │ └── v1beta1.json
│ │ │ │ │ └── v1.json
│ │ │ │ ├── swagger.json
│ │ │ │ └── swagger_next.json
│ │ │ ├── testing/
│ │ │ │ ├── openapi.go
│ │ │ │ └── openapi_v3.go
│ │ │ └── validation/
│ │ │ ├── errors.go
│ │ │ ├── types.go
│ │ │ ├── validation.go
│ │ │ └── validation_test.go
│ │ ├── sets/
│ │ │ ├── empty.go
│ │ │ └── string.go
│ │ ├── trie.go
│ │ ├── util.go
│ │ └── util_test.go
│ └── validation/
│ ├── OWNERS
│ ├── errors/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── api.go
│ │ ├── api_test.go
│ │ ├── doc.go
│ │ ├── headers.go
│ │ ├── schema.go
│ │ └── schema_test.go
│ ├── spec/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── contact_info.go
│ │ ├── contact_info_test.go
│ │ ├── external_docs.go
│ │ ├── external_docs_test.go
│ │ ├── fuzz_test.go
│ │ ├── gnostic.go
│ │ ├── gnostic_test.go
│ │ ├── header.go
│ │ ├── header_test.go
│ │ ├── info.go
│ │ ├── info_test.go
│ │ ├── items.go
│ │ ├── items_test.go
│ │ ├── license.go
│ │ ├── license_test.go
│ │ ├── operation.go
│ │ ├── operation_test.go
│ │ ├── parameter.go
│ │ ├── parameters_test.go
│ │ ├── path_item.go
│ │ ├── path_item_test.go
│ │ ├── paths.go
│ │ ├── paths_test.go
│ │ ├── ref.go
│ │ ├── ref_test.go
│ │ ├── response.go
│ │ ├── response_test.go
│ │ ├── responses.go
│ │ ├── responses_test.go
│ │ ├── schema.go
│ │ ├── schema_test.go
│ │ ├── security_scheme.go
│ │ ├── security_scheme_test.go
│ │ ├── structs_test.go
│ │ ├── swagger.go
│ │ ├── swagger_test.go
│ │ ├── tag.go
│ │ └── tag_test.go
│ ├── strfmt/
│ │ ├── .github/
│ │ │ └── CONTRIBUTING.md
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── bson/
│ │ │ └── objectid.go
│ │ ├── bson.go
│ │ ├── bson_test.go
│ │ ├── date.go
│ │ ├── date_test.go
│ │ ├── default.go
│ │ ├── default_test.go
│ │ ├── doc.go
│ │ ├── duration.go
│ │ ├── duration_test.go
│ │ ├── format.go
│ │ ├── format_test.go
│ │ ├── kubernetes-extensions.go
│ │ ├── kubernetes-extensions_test.go
│ │ ├── time.go
│ │ └── time_test.go
│ └── validate/
│ ├── .github/
│ │ └── CONTRIBUTING.md
│ ├── .gitignore
│ ├── LICENSE
│ ├── debug.go
│ ├── debug_test.go
│ ├── doc.go
│ ├── doc_test.go
│ ├── fixtures/
│ │ ├── formats/
│ │ │ └── extended-format.json
│ │ ├── jsonschema_suite/
│ │ │ ├── additionalItems.json
│ │ │ ├── additionalProperties.json
│ │ │ ├── allOf.json
│ │ │ ├── anyOf.json
│ │ │ ├── default.json
│ │ │ ├── dependencies.json
│ │ │ ├── enum.json
│ │ │ ├── format.json
│ │ │ ├── items.json
│ │ │ ├── maxItems.json
│ │ │ ├── maxLength.json
│ │ │ ├── maxProperties.json
│ │ │ ├── maximum.json
│ │ │ ├── minItems.json
│ │ │ ├── minLength.json
│ │ │ ├── minProperties.json
│ │ │ ├── minimum.json
│ │ │ ├── multipleOf.json
│ │ │ ├── not.json
│ │ │ ├── oneOf.json
│ │ │ ├── optional/
│ │ │ │ ├── bignum.json
│ │ │ │ ├── ecmascript-regex.json
│ │ │ │ ├── format.json
│ │ │ │ └── zeroTerminatedFloats.json
│ │ │ ├── pattern.json
│ │ │ ├── patternProperties.json
│ │ │ ├── properties.json
│ │ │ ├── required.json
│ │ │ ├── type.json
│ │ │ └── uniqueItems.json
│ │ └── schemas/
│ │ └── int-enum.json
│ ├── formats.go
│ ├── formats_test.go
│ ├── helpers.go
│ ├── helpers_test.go
│ ├── jsonschema_test.go
│ ├── object_validator.go
│ ├── object_validator_test.go
│ ├── options.go
│ ├── options_test.go
│ ├── result.go
│ ├── result_test.go
│ ├── rexp.go
│ ├── rexp_test.go
│ ├── schema.go
│ ├── schema_messages.go
│ ├── schema_option.go
│ ├── schema_props.go
│ ├── schema_props_test.go
│ ├── schema_test.go
│ ├── slice_validator.go
│ ├── slice_validator_test.go
│ ├── type.go
│ ├── type_test.go
│ ├── validator.go
│ ├── validator_test.go
│ ├── values.go
│ └── values_test.go
└── test/
└── integration/
├── README.md
├── builder/
│ └── main.go
├── builder3/
│ └── main.go
├── go.mod
├── go.sum
├── import.go
├── integration_suite_test.go
├── naming_test.go
├── openapiconv/
│ └── convert_test.go
├── pkg/
│ └── generated/
│ ├── namedmodels/
│ │ └── openapi_generated.go
│ └── openapi_generated.go
├── testdata/
│ ├── aggregator/
│ │ ├── openapi-0.json
│ │ ├── openapi-1.json
│ │ ├── openapi-2.json
│ │ └── openapi.json
│ ├── custom/
│ │ ├── v2.go
│ │ └── v3.go
│ ├── defaults/
│ │ └── default.go
│ ├── dummytype/
│ │ ├── alpha.go
│ │ └── beta.go
│ ├── enumtype/
│ │ └── enum.go
│ ├── golden.v2.json
│ ├── golden.v2.report
│ ├── golden.v3.json
│ ├── listtype/
│ │ ├── atomic-list.go
│ │ ├── map-list.go
│ │ ├── set-list.go
│ │ └── untyped.go
│ ├── maptype/
│ │ ├── atomic-map.go
│ │ └── granular-map.go
│ ├── namedmodels/
│ │ ├── doc.go
│ │ ├── golden.v3.json
│ │ ├── golden.v3.report
│ │ ├── struct.go
│ │ └── zz_generated_model_name.go
│ ├── structtype/
│ │ ├── atomic-struct.go
│ │ ├── field-level-override.go
│ │ └── granular-struct.go
│ ├── uniontype/
│ │ └── union.go
│ └── valuevalidation/
│ └── alpha.go
└── testutil/
└── testutil.go
Showing preview only (255K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2825 symbols across 264 files)
FILE: cmd/openapi-gen/args/args.go
type Args (line 25) | type Args struct
method AddFlags (line 62) | func (args *Args) AddFlags(fs *pflag.FlagSet) {
method Validate (line 86) | func (args *Args) Validate() error {
function New (line 52) | func New() *Args {
FILE: cmd/openapi-gen/openapi-gen.go
function main (line 36) | func main() {
FILE: cmd/openapi2smd/openapi2smd.go
function main (line 31) | func main() {
FILE: pkg/aggregator/aggregator.go
constant gvkKey (line 30) | gvkKey = "x-kubernetes-group-version-kind"
function usedDefinitionForSpec (line 33) | func usedDefinitionForSpec(root *spec.Swagger) map[string]bool {
function FilterSpecByPaths (line 46) | func FilterSpecByPaths(sp *spec.Swagger, keepPathPrefixes []string) {
function FilterSpecByPathsWithoutSideEffects (line 54) | func FilterSpecByPathsWithoutSideEffects(sp *spec.Swagger, keepPathPrefi...
function renameDefinitions (line 95) | func renameDefinitions(s *spec.Swagger, renames map[string]string) *spec...
function renameParameters (line 135) | func renameParameters(s *spec.Swagger, renames map[string]string) *spec....
function MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters (line 176) | func MergeSpecsIgnorePathConflictRenamingDefinitionsAndParameters(dest, ...
function MergeSpecsIgnorePathConflictDeprecated (line 183) | func MergeSpecsIgnorePathConflictDeprecated(dest, source *spec.Swagger) ...
function MergeSpecsFailOnDefinitionConflict (line 189) | func MergeSpecsFailOnDefinitionConflict(dest, source *spec.Swagger) error {
function MergeSpecs (line 197) | func MergeSpecs(dest, source *spec.Swagger) error {
function mergeSpecs (line 203) | func mergeSpecs(dest, source *spec.Swagger, renameModelConflicts, rename...
function deepEqualDefinitionsModuloGVKs (line 356) | func deepEqualDefinitionsModuloGVKs(s1, s2 *spec.Schema) bool {
function mergedGVKs (line 400) | func mergedGVKs(s1, s2 *spec.Schema) (interface{}, bool, error) {
type byKeys (line 455) | type byKeys struct
method Len (line 460) | func (b byKeys) Len() int {
method Less (line 464) | func (b byKeys) Less(i, j int) bool {
method Swap (line 468) | func (b byKeys) Swap(i, j int) {
FILE: pkg/aggregator/aggregator_test.go
type DebugSpec (line 35) | type DebugSpec struct
method String (line 39) | func (d DebugSpec) String() string {
function TestFilterSpecs (line 46) | func TestFilterSpecs(t *testing.T) {
function TestFilterSpecsWithUnusedDefinitions (line 195) | func TestFilterSpecsWithUnusedDefinitions(t *testing.T) {
function TestMergeSpecsSimple (line 302) | func TestMergeSpecsSimple(t *testing.T) {
function TestMergeSpecsEmptyDefinitions (line 464) | func TestMergeSpecsEmptyDefinitions(t *testing.T) {
function TestMergeSpecsEmptyPaths (line 568) | func TestMergeSpecsEmptyPaths(t *testing.T) {
function TestMergeSpecsReuseModel (line 668) | func TestMergeSpecsReuseModel(t *testing.T) {
function TestMergeSpecsRenameModel (line 823) | func TestMergeSpecsRenameModel(t *testing.T) {
function TestMergeSpecsRenameModelWithExistingV2InDestination (line 988) | func TestMergeSpecsRenameModelWithExistingV2InDestination(t *testing.T) {
function TestMergeSpecsMultipleRenamesOfModelsAndLateConflict (line 1108) | func TestMergeSpecsMultipleRenamesOfModelsAndLateConflict(t *testing.T) {
function TestMergeSpecsRenameModelWithExistingV2InSource (line 1260) | func TestMergeSpecsRenameModelWithExistingV2InSource(t *testing.T) {
function TestTwoMergeSpecsFirstTwoSchemasHaveSameDefinition (line 1383) | func TestTwoMergeSpecsFirstTwoSchemasHaveSameDefinition(t *testing.T) {
function TestTwoMergeSpecsLastTwoSchemasHaveSameDefinition (line 1477) | func TestTwoMergeSpecsLastTwoSchemasHaveSameDefinition(t *testing.T) {
function TestSafeMergeSpecsSimple (line 1567) | func TestSafeMergeSpecsSimple(t *testing.T) {
function TestSafeMergeSpecsReuseModel (line 1679) | func TestSafeMergeSpecsReuseModel(t *testing.T) {
function TestSafeMergeSpecsReuseModelFails (line 1812) | func TestSafeMergeSpecsReuseModelFails(t *testing.T) {
function TestMergeSpecsIgnorePathConflicts (line 1912) | func TestMergeSpecsIgnorePathConflicts(t *testing.T) {
function TestMergeSpecsIgnorePathConflictsAllConflicting (line 2031) | func TestMergeSpecsIgnorePathConflictsAllConflicting(t *testing.T) {
function TestMergeSpecsIgnorePathConflictsWithKubeSpec (line 2069) | func TestMergeSpecsIgnorePathConflictsWithKubeSpec(t *testing.T) {
function BenchmarkMergeSpecsIgnorePathConflictsWithKubeSpec (line 2098) | func BenchmarkMergeSpecsIgnorePathConflictsWithKubeSpec(b *testing.B) {
function TestMergeSpecReplacesAllPossibleRefs (line 2126) | func TestMergeSpecReplacesAllPossibleRefs(t *testing.T) {
function loadTestData (line 2325) | func loadTestData() ([]*spec.Swagger, *spec.Swagger) {
function TestCloneSpec (line 2349) | func TestCloneSpec(t *testing.T) {
function cloneSpec (line 2359) | func cloneSpec(source *spec.Swagger) (*spec.Swagger, error) {
function TestMergedGVKs (line 2372) | func TestMergedGVKs(t *testing.T) {
function TestDeepEqualDefinitionsModuloGVKs (line 2427) | func TestDeepEqualDefinitionsModuloGVKs(t *testing.T) {
FILE: pkg/aggregator/walker.go
constant definitionPrefix (line 26) | definitionPrefix = "#/definitions/"
constant parameterPrefix (line 27) | parameterPrefix = "#/parameters/"
type readonlyReferenceWalker (line 31) | type readonlyReferenceWalker struct
method walkSchema (line 74) | func (s *readonlyReferenceWalker) walkSchema(schema *spec.Schema) {
method walkParams (line 123) | func (s *readonlyReferenceWalker) walkParams(params []spec.Parameter) {
method walkParam (line 132) | func (s *readonlyReferenceWalker) walkParam(param spec.Parameter) {
method walkResponse (line 140) | func (s *readonlyReferenceWalker) walkResponse(resp *spec.Response) {
method walkOperation (line 148) | func (s *readonlyReferenceWalker) walkOperation(op *spec.Operation) {
method Start (line 162) | func (s *readonlyReferenceWalker) Start() {
function walkOnAllReferences (line 41) | func walkOnAllReferences(walkRef func(ref *spec.Ref), root *spec.Swagger) {
FILE: pkg/builder/openapi.go
constant OpenAPIVersion (line 34) | OpenAPIVersion = "2.0"
type openAPI (line 37) | type openAPI struct
method finalizeSwagger (line 142) | func (o *openAPI) finalizeSwagger() (*spec.Swagger, error) {
method buildDefinitionRecursively (line 158) | func (o *openAPI) buildDefinitionRecursively(name string) error {
method buildDefinitionForType (line 198) | func (o *openAPI) buildDefinitionForType(name string) (string, error) {
method buildPaths (line 207) | func (o *openAPI) buildPaths(routeContainers []common.RouteContainer) ...
method buildOperations (line 284) | func (o *openAPI) buildOperations(route common.Route, inPathCommonPara...
method buildResponse (line 348) | func (o *openAPI) buildResponse(model interface{}, description string)...
method findCommonParameters (line 361) | func (o *openAPI) findCommonParameters(routes []common.Route) (map[int...
method toSchema (line 395) | func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) {
method buildParameter (line 416) | func (o *openAPI) buildParameter(restParam common.Parameter, bodySampl...
method buildParameters (line 460) | func (o *openAPI) buildParameters(restParam []common.Parameter) (ret [...
function BuildOpenAPISpec (line 47) | func BuildOpenAPISpec(routeContainers []*restful.WebService, config *com...
function BuildOpenAPISpecFromRoutes (line 52) | func BuildOpenAPISpecFromRoutes(routeContainers []common.RouteContainer,...
function BuildOpenAPIDefinitionsForResource (line 62) | func BuildOpenAPIDefinitionsForResource(model interface{}, config *commo...
function BuildOpenAPIDefinitionsForResources (line 79) | func BuildOpenAPIDefinitionsForResources(config *common.Config, names .....
function newOpenAPI (line 93) | func newOpenAPI(config *common.Config) openAPI {
FILE: pkg/builder/openapi_test.go
function setUp (line 35) | func setUp(t *testing.T, fullMethods bool) (*openapi.Config, *restful.Co...
function noOp (line 41) | func noOp(request *restful.Request, response *restful.Response) {}
type TestInput (line 44) | type TestInput struct
method OpenAPIDefinition (line 90) | func (_ TestInput) OpenAPIDefinition() openapi.OpenAPIDefinition {
type TestOutput (line 53) | type TestOutput struct
method OpenAPIDefinition (line 130) | func (_ TestOutput) OpenAPIDefinition() openapi.OpenAPIDefinition {
type TestExtensionV2Schema (line 60) | type TestExtensionV2Schema struct
method OpenAPIDefinition (line 62) | func (_ TestExtensionV2Schema) OpenAPIDefinition() openapi.OpenAPIDefi...
function getTestRoute (line 158) | func getTestRoute(ws *restful.WebService, method string, additionalParam...
function getConfig (line 178) | func getConfig(fullMethods bool) (*openapi.Config, *restful.Container) {
function getTestOperation (line 229) | func getTestOperation(method string, opPrefix string) *spec.Operation {
function getTestPathItem (line 243) | func getTestPathItem(allMethods bool, opPrefix string) spec.PathItem {
function getRefSchema (line 268) | func getRefSchema(ref string) *spec.Schema {
function getTestResponses (line 276) | func getTestResponses() *spec.Responses {
function getTestCommonParameters (line 291) | func getTestCommonParameters() []spec.Parameter {
function getTestParameters (line 306) | func getTestParameters() []spec.Parameter {
function getAdditionalTestParameters (line 319) | func getAdditionalTestParameters() []spec.Parameter {
function getTestInputDefinition (line 342) | func getTestInputDefinition() spec.Schema {
function getTestOutputDefinition (line 383) | func getTestOutputDefinition() spec.Schema {
function TestBuildOpenAPISpec (line 411) | func TestBuildOpenAPISpec(t *testing.T) {
function TestBuildOpenAPIDefinitionsForResource (line 507) | func TestBuildOpenAPIDefinitionsForResource(t *testing.T) {
function TestBuildOpenAPIDefinitionsForResourceWithExtensionV2Schema (line 529) | func TestBuildOpenAPIDefinitionsForResourceWithExtensionV2Schema(t *test...
type TestRecursiveType (line 553) | type TestRecursiveType struct
function makeRecursiveTypeDefinition (line 558) | func makeRecursiveTypeDefinition(depName string) openapi.OpenAPIDefiniti...
function TestEscapeJsonPointerInDefinitionName (line 587) | func TestEscapeJsonPointerInDefinitionName(t *testing.T) {
FILE: pkg/builder/parameters.go
function deduplicateParameters (line 35) | func deduplicateParameters(sp *spec.Swagger) (*spec.Swagger, error) {
function collectSharedParameters (line 54) | func collectSharedParameters(sp *spec.Swagger) (namesByJSON map[string]s...
function operations (line 146) | func operations(path *spec.PathItem) []*spec.Operation {
function base64Hash (line 150) | func base64Hash(s string) string {
function replaceSharedParameters (line 156) | func replaceSharedParameters(sharedParameterNamesByJSON map[string]strin...
FILE: pkg/builder/parameters_test.go
function TestCollectSharedParameters (line 29) | func TestCollectSharedParameters(t *testing.T) {
function TestReplaceSharedParameters (line 145) | func TestReplaceSharedParameters(t *testing.T) {
function toJSON (line 229) | func toJSON(t *testing.T, x interface{}) string {
function normalizeJSON (line 236) | func normalizeJSON(t *testing.T, j string) string {
function TestOperations (line 243) | func TestOperations(t *testing.T) {
FILE: pkg/builder/util.go
type parameters (line 26) | type parameters
method Len (line 28) | func (s parameters) Len() int { return len(s) }
method Swap (line 29) | func (s parameters) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type byNameIn (line 32) | type byNameIn struct
method Less (line 36) | func (s byNameIn) Less(i, j int) bool {
function sortParameters (line 41) | func sortParameters(p []spec.Parameter) {
function groupRoutesByPath (line 45) | func groupRoutesByPath(routes []common.Route) map[string][]common.Route {
function mapKeyFromParam (line 53) | func mapKeyFromParam(param common.Parameter) interface{} {
FILE: pkg/builder3/openapi.go
constant OpenAPIVersion (line 36) | OpenAPIVersion = "3.0"
type openAPI (line 39) | type openAPI struct
method buildResponse (line 53) | func (o *openAPI) buildResponse(model interface{}, description string,...
method buildOperations (line 76) | func (o *openAPI) buildOperations(route common.Route, inPathCommonPara...
method buildRequestBody (line 150) | func (o *openAPI) buildRequestBody(parameters []common.Parameter, cons...
method buildOpenAPISpec (line 243) | func (o *openAPI) buildOpenAPISpec(webServices []common.RouteContainer...
method findCommonParameters (line 353) | func (o *openAPI) findCommonParameters(routes []common.Route) (map[int...
method buildParameters (line 387) | func (o *openAPI) buildParameters(restParam []common.Parameter) (ret [...
method buildParameter (line 398) | func (o *openAPI) buildParameter(restParam common.Parameter) (ret *spe...
method buildDefinitionRecursively (line 437) | func (o *openAPI) buildDefinitionRecursively(name string) error {
method buildDefinitionForType (line 472) | func (o *openAPI) buildDefinitionForType(name string) (string, error) {
method toSchema (line 480) | func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) {
function groupRoutesByPath (line 45) | func groupRoutesByPath(routes []common.Route) map[string][]common.Route {
function newOpenAPI (line 177) | func newOpenAPI(config *common.OpenAPIV3Config) openAPI {
function BuildOpenAPISpec (line 321) | func BuildOpenAPISpec(webServices []*restful.WebService, config *common....
function BuildOpenAPISpecFromRoutes (line 326) | func BuildOpenAPISpecFromRoutes(webServices []common.RouteContainer, con...
function BuildOpenAPIDefinitionsForResources (line 341) | func BuildOpenAPIDefinitionsForResources(config *common.OpenAPIV3Config,...
FILE: pkg/builder3/openapi_test.go
function setUp (line 36) | func setUp(t *testing.T, fullMethods bool) (*openapi.OpenAPIV3Config, *r...
function noOp (line 42) | func noOp(request *restful.Request, response *restful.Response) {}
type TestInput (line 45) | type TestInput struct
method OpenAPIDefinition (line 61) | func (_ TestInput) OpenAPIDefinition() openapi.OpenAPIDefinition {
type TestOutput (line 54) | type TestOutput struct
method OpenAPIDefinition (line 124) | func (_ TestOutput) OpenAPIDefinition() openapi.OpenAPIDefinition {
function getTestRoute (line 152) | func getTestRoute(ws *restful.WebService, method string, opPrefix string...
function getConfig (line 168) | func getConfig(fullMethods bool) (*openapi.OpenAPIV3Config, *restful.Con...
function getTestOperation (line 217) | func getTestOperation(method string, opPrefix string) *spec3.Operation {
function getTestPathItem (line 228) | func getTestPathItem(opPrefix string) *spec3.Path {
function getRefSchema (line 251) | func getRefSchema(ref string) *spec.Schema {
function getTestResponses (line 259) | func getTestResponses() *spec3.Responses {
function getTestCommonParameters (line 281) | func getTestCommonParameters() []*spec3.Parameter {
function getTestRequestBody (line 313) | func getTestRequestBody() *spec3.RequestBody {
function getTestInputDefinition (line 329) | func getTestInputDefinition() *spec.Schema {
function getTestOutputDefinition (line 402) | func getTestOutputDefinition() *spec.Schema {
function TestBuildOpenAPISpec (line 430) | func TestBuildOpenAPISpec(t *testing.T) {
type TestRecursiveType (line 482) | type TestRecursiveType struct
function makeRecursiveTypeDefinition (line 487) | func makeRecursiveTypeDefinition(depName string) openapi.OpenAPIDefiniti...
function TestEscapeJsonPointerInSchemaName (line 516) | func TestEscapeJsonPointerInSchemaName(t *testing.T) {
FILE: pkg/builder3/util.go
function mapKeyFromParam (line 26) | func mapKeyFromParam(param common.Parameter) interface{} {
type parameters (line 39) | type parameters
method Len (line 36) | func (s parameters) Len() int { return len(s) }
method Swap (line 37) | func (s parameters) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type byNameIn (line 41) | type byNameIn struct
method Less (line 45) | func (s byNameIn) Less(i, j int) bool {
function sortParameters (line 50) | func sortParameters(p []*spec3.Parameter) {
FILE: pkg/builder3/util/util.go
function WrapRefs (line 29) | func WrapRefs(schema *spec.Schema) *spec.Schema {
FILE: pkg/cached/cache.go
type Value (line 60) | type Value interface
type Result (line 66) | type Result struct
method Get (line 72) | func (r Result[T]) Get() (T, string, error) {
function Func (line 77) | func Func[T any](fn func() (T, string, error)) Value[T] {
type valueFunc (line 81) | type valueFunc
method Get (line 83) | func (c valueFunc[T]) Get() (T, string, error) {
function Static (line 88) | func Static[T any](value T, etag string) Value[T] {
function Merge (line 107) | func Merge[K comparable, T, V any](mergeFn func(results map[K]Result[T])...
function MergeList (line 146) | func MergeList[T, V any](mergeFn func(results []Result[T]) (V, string, e...
type listMerger (line 153) | type listMerger struct
method prepareResultsLocked (line 161) | func (c *listMerger[T, V]) prepareResultsLocked() []Result[T] {
method needsRunningLocked (line 183) | func (c *listMerger[T, V]) needsRunningLocked(results []Result[T]) bool {
method Get (line 202) | func (c *listMerger[T, V]) Get() (V, string, error) {
function Transform (line 219) | func Transform[T, V any](transformerFn func(T, string, error) (V, string...
function Once (line 229) | func Once[T any](d Value[T]) Value[T] {
type once (line 235) | type once struct
method Get (line 241) | func (c *once[T]) Get() (T, string, error) {
type Replaceable (line 250) | type Replaceable interface
type Atomic (line 257) | type Atomic struct
method Store (line 263) | func (x *Atomic[T]) Store(val Value[T]) { x.value.Store(&val) }
method Get (line 264) | func (x *Atomic[T]) Get() (T, string, error) { return (*x.value.Load())....
type LastSuccess (line 268) | type LastSuccess struct
method Get (line 275) | func (c *LastSuccess[T]) Get() (T, string, error) {
FILE: pkg/cached/cache_test.go
function TestDataFunc (line 34) | func TestDataFunc(t *testing.T) {
function TestDataFuncError (line 51) | func TestDataFuncError(t *testing.T) {
function TestDataFuncAlternate (line 68) | func TestDataFuncAlternate(t *testing.T) {
function TestOnce (line 94) | func TestOnce(t *testing.T) {
function TestOnceError (line 111) | func TestOnceError(t *testing.T) {
function TestResultGet (line 128) | func TestResultGet(t *testing.T) {
function TestResultGetError (line 142) | func TestResultGetError(t *testing.T) {
function TestTransform (line 156) | func TestTransform(t *testing.T) {
function TestTransformChained (line 184) | func TestTransformChained(t *testing.T) {
function TestTransformError (line 241) | func TestTransformError(t *testing.T) {
function TestTransformSourceError (line 266) | func TestTransformSourceError(t *testing.T) {
function TestTransformAlternateSourceError (line 294) | func TestTransformAlternateSourceError(t *testing.T) {
function TestMerge (line 346) | func TestMerge(t *testing.T) {
function TestMergeError (line 401) | func TestMergeError(t *testing.T) {
function TestMergeSourceError (line 437) | func TestMergeSourceError(t *testing.T) {
function TestMergeAlternateSourceError (line 484) | func TestMergeAlternateSourceError(t *testing.T) {
function TestAtomic (line 555) | func TestAtomic(t *testing.T) {
function TestLastSuccess (line 632) | func TestLastSuccess(t *testing.T) {
function TestLastSuccessEtag (line 711) | func TestLastSuccessEtag(t *testing.T) {
function TestLastSuccessAlternateError (line 726) | func TestLastSuccessAlternateError(t *testing.T) {
function TestLastSuccessWithTransformer (line 783) | func TestLastSuccessWithTransformer(t *testing.T) {
function Example (line 848) | func Example() {
function TestListMerger (line 937) | func TestListMerger(t *testing.T) {
function TestMergeListSourceError (line 989) | func TestMergeListSourceError(t *testing.T) {
function TestMergeListAlternateSourceError (line 1033) | func TestMergeListAlternateSourceError(t *testing.T) {
function TestListDAG (line 1101) | func TestListDAG(t *testing.T) {
function randomString (line 1143) | func randomString(length uint) string {
function NewRandomSource (line 1150) | func NewRandomSource() cached.Value[int64] {
function repeatedGet (line 1158) | func repeatedGet(data cached.Value[int64], end time.Time, wg *sync.WaitG...
function TestThreadSafe (line 1165) | func TestThreadSafe(t *testing.T) {
FILE: pkg/common/common.go
constant ExtensionPrefix (line 31) | ExtensionPrefix = "x-kubernetes-"
constant ExtensionV2Schema (line 32) | ExtensionV2Schema = ExtensionPrefix + "v2-schema"
type OpenAPIDefinition (line 36) | type OpenAPIDefinition struct
type ReferenceCallback (line 41) | type ReferenceCallback
type GetOpenAPIDefinitions (line 44) | type GetOpenAPIDefinitions
type OpenAPIDefinitionGetter (line 50) | type OpenAPIDefinitionGetter interface
type OpenAPIV3DefinitionGetter (line 54) | type OpenAPIV3DefinitionGetter interface
type PathHandler (line 58) | type PathHandler interface
type PathHandlerByGroupVersion (line 62) | type PathHandlerByGroupVersion interface
type Config (line 68) | type Config struct
type OpenAPIV3Config (line 126) | type OpenAPIV3Config struct
type typeInfo (line 177) | type typeInfo struct
function OpenAPITypeFormat (line 250) | func OpenAPITypeFormat(typeName string) (string, string) {
function OpenAPIZeroValue (line 260) | func OpenAPIZeroValue(typeName string) (interface{}, bool) {
function EscapeJsonPointer (line 268) | func EscapeJsonPointer(p string) string {
function EmbedOpenAPIDefinitionIntoV2Extension (line 275) | func EmbedOpenAPIDefinitionIntoV2Extension(main OpenAPIDefinition, embed...
function GenerateOpenAPIV3OneOfSchema (line 284) | func GenerateOpenAPIV3OneOfSchema(types []string) (oneOf []spec.Schema) {
FILE: pkg/common/interfaces.go
type RouteContainer (line 5) | type RouteContainer interface
type Route (line 15) | type Route interface
type StatusCodeResponse (line 42) | type StatusCodeResponse interface
type Parameter (line 52) | type Parameter interface
type ParameterKind (line 68) | type ParameterKind
constant PathParameterKind (line 72) | PathParameterKind = ParameterKind(iota)
constant QueryParameterKind (line 75) | QueryParameterKind
constant BodyParameterKind (line 78) | BodyParameterKind
constant HeaderParameterKind (line 81) | HeaderParameterKind
constant FormParameterKind (line 84) | FormParameterKind
constant UnknownParameterKind (line 87) | UnknownParameterKind
FILE: pkg/common/restfuladapter/adapter.go
function AdaptWebServices (line 9) | func AdaptWebServices(webServices []*restful.WebService) []common.RouteC...
FILE: pkg/common/restfuladapter/param_adapter.go
type ParamAdapter (line 11) | type ParamAdapter struct
method MarshalJSON (line 15) | func (r *ParamAdapter) MarshalJSON() ([]byte, error) {
method Name (line 19) | func (r *ParamAdapter) Name() string {
method Description (line 23) | func (r *ParamAdapter) Description() string {
method Required (line 27) | func (r *ParamAdapter) Required() bool {
method Kind (line 31) | func (r *ParamAdapter) Kind() common.ParameterKind {
method DataType (line 48) | func (r *ParamAdapter) DataType() string {
method AllowMultiple (line 52) | func (r *ParamAdapter) AllowMultiple() bool {
FILE: pkg/common/restfuladapter/response_error_adapter.go
type ResponseErrorAdapter (line 11) | type ResponseErrorAdapter struct
method Message (line 15) | func (r *ResponseErrorAdapter) Message() string {
method Model (line 19) | func (r *ResponseErrorAdapter) Model() interface{} {
method Code (line 23) | func (r *ResponseErrorAdapter) Code() int {
FILE: pkg/common/restfuladapter/route_adapter.go
type RouteAdapter (line 11) | type RouteAdapter struct
method StatusCodeResponses (line 15) | func (r *RouteAdapter) StatusCodeResponses() []common.StatusCodeRespon...
method OperationName (line 26) | func (r *RouteAdapter) OperationName() string {
method Method (line 30) | func (r *RouteAdapter) Method() string {
method Path (line 34) | func (r *RouteAdapter) Path() string {
method Parameters (line 38) | func (r *RouteAdapter) Parameters() []common.Parameter {
method Description (line 46) | func (r *RouteAdapter) Description() string {
method Consumes (line 50) | func (r *RouteAdapter) Consumes() []string {
method Produces (line 54) | func (r *RouteAdapter) Produces() []string {
method Metadata (line 58) | func (r *RouteAdapter) Metadata() map[string]interface{} {
method RequestPayloadSample (line 62) | func (r *RouteAdapter) RequestPayloadSample() interface{} {
method ResponsePayloadSample (line 66) | func (r *RouteAdapter) ResponsePayloadSample() interface{} {
FILE: pkg/common/restfuladapter/webservice_adapter.go
type WebServiceAdapter (line 11) | type WebServiceAdapter struct
method RootPath (line 15) | func (r *WebServiceAdapter) RootPath() string {
method PathParameters (line 19) | func (r *WebServiceAdapter) PathParameters() []common.Parameter {
method Routes (line 27) | func (r *WebServiceAdapter) Routes() []common.Route {
FILE: pkg/generators/api_linter.go
constant apiViolationFileType (line 33) | apiViolationFileType = "api-violation"
type apiViolationFile (line 35) | type apiViolationFile struct
method AssembleFile (line 41) | func (a apiViolationFile) AssembleFile(f *generator.File, path string)...
method VerifyFile (line 58) | func (a apiViolationFile) VerifyFile(f *generator.File, path string) e...
function newAPIViolationGen (line 90) | func newAPIViolationGen() *apiViolationGen {
type apiViolationGen (line 96) | type apiViolationGen struct
method FileType (line 102) | func (v *apiViolationGen) FileType() string { return apiViolationFileT...
method Filename (line 103) | func (v *apiViolationGen) Filename() string {
method GenerateType (line 107) | func (v *apiViolationGen) GenerateType(c *generator.Context, t *types....
method Finalize (line 117) | func (v *apiViolationGen) Finalize(c *generator.Context, w io.Writer) ...
type apiLinter (line 128) | type apiLinter struct
method validate (line 193) | func (l *apiLinter) validate(t *types.Type) error {
method report (line 213) | func (l *apiLinter) report(w io.Writer) error {
function newAPILinter (line 136) | func newAPILinter() *apiLinter {
type apiViolation (line 150) | type apiViolation struct
type apiViolations (line 164) | type apiViolations
method Len (line 166) | func (a apiViolations) Len() int { return len(a) }
method Swap (line 167) | func (a apiViolations) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
method Less (line 168) | func (a apiViolations) Less(i, j int) bool {
type APIRule (line 182) | type APIRule interface
FILE: pkg/generators/config.go
type identityNamer (line 29) | type identityNamer struct
method Name (line 31) | func (_ identityNamer) Name(t *types.Type) string {
function NameSystems (line 38) | func NameSystems() namer.NameSystems {
function DefaultNameSystem (line 47) | func DefaultNameSystem() string {
function GetOpenAPITargets (line 52) | func GetOpenAPITargets(context *generator.Context, args *args.Args, boil...
function isReadOnlyPkg (line 83) | func isReadOnlyPkg(pkgPath string, readOnlyPkgs []string) bool {
function GetModelNameTargets (line 93) | func GetModelNameTargets(context *generator.Context, args *args.Args, bo...
FILE: pkg/generators/config_test.go
function TestIsReadOnlyPkg (line 27) | func TestIsReadOnlyPkg(t *testing.T) {
function TestGetModelNameTargets_ReadOnlyPkgs (line 82) | func TestGetModelNameTargets_ReadOnlyPkgs(t *testing.T) {
FILE: pkg/generators/enum.go
constant tagEnumType (line 30) | tagEnumType = "enum"
constant enumTypeDescriptionHeader (line 31) | enumTypeDescriptionHeader = "Possible enum values:"
type enumValue (line 33) | type enumValue struct
method Description (line 154) | func (ev *enumValue) Description() string {
type enumType (line 39) | type enumType struct
method ValueStrings (line 69) | func (et *enumType) ValueStrings() []string {
method DescriptionLines (line 84) | func (et *enumType) DescriptionLines() []string {
method addIfNotPresent (line 133) | func (et *enumType) addIfNotPresent(value *enumValue) {
type enumMap (line 45) | type enumMap
type enumContext (line 47) | type enumContext struct
method EnumType (line 58) | func (ec *enumContext) EnumType(t *types.Type) (enum *enumType, isEnum...
function newEnumContext (line 51) | func newEnumContext(c *generator.Context) *enumContext {
function parseEnums (line 97) | func parseEnums(c *generator.Context) enumMap {
function isEnumType (line 168) | func isEnumType(stringType *types.Type, t *types.Type) bool {
function hasEnumTag (line 172) | func hasEnumTag(t *types.Type) bool {
FILE: pkg/generators/enum_test.go
function TestParseEnums (line 28) | func TestParseEnums(t *testing.T) {
FILE: pkg/generators/extension.go
constant extensionPrefix (line 29) | extensionPrefix = "x-kubernetes-"
type extensionAttributes (line 32) | type extensionAttributes struct
type extension (line 77) | type extension struct
method hasAllowedValues (line 83) | func (e extension) hasAllowedValues() bool {
method allowedValues (line 87) | func (e extension) allowedValues() sets.String {
method hasKind (line 91) | func (e extension) hasKind() bool {
method kind (line 95) | func (e extension) kind() types.Kind {
method validateAllowedValues (line 99) | func (e extension) validateAllowedValues() error {
method validateType (line 117) | func (e extension) validateType(kind types.Kind) error {
method hasMultipleValues (line 129) | func (e extension) hasMultipleValues() bool {
method isAlwaysArrayFormat (line 133) | func (e extension) isAlwaysArrayFormat() bool {
function sortedMapKeys (line 138) | func sortedMapKeys(m map[string][]string) []string {
function parseExtensions (line 153) | func parseExtensions(comments []string) ([]extension, []error) {
function validateMemberExtensions (line 192) | func validateMemberExtensions(extensions []extension, m *types.Member) [...
FILE: pkg/generators/extension_test.go
function TestSingleTagExtension (line 28) | func TestSingleTagExtension(t *testing.T) {
function TestMultipleTagExtensions (line 110) | func TestMultipleTagExtensions(t *testing.T) {
function TestExtensionParseErrors (line 150) | func TestExtensionParseErrors(t *testing.T) {
function TestExtensionAllowedValues (line 184) | func TestExtensionAllowedValues(t *testing.T) {
function TestExtensionKind (line 351) | func TestExtensionKind(t *testing.T) {
function TestValidateMemberExtensions (line 416) | func TestValidateMemberExtensions(t *testing.T) {
FILE: pkg/generators/markers.go
type CELTag (line 34) | type CELTag struct
method Validate (line 43) | func (c *CELTag) Validate() error {
function isKnownTagCommentKey (line 70) | func isKnownTagCommentKey(key string) bool {
type commentTags (line 107) | type commentTags struct
method ValidationSchema (line 141) | func (c *commentTags) ValidationSchema() (*spec.Schema, error) {
method Validate (line 242) | func (c commentTags) Validate() error {
method ValidateType (line 301) | func (c commentTags) ValidateType(t *types.Type) error {
function memberWithJSONName (line 404) | func memberWithJSONName(t *types.Type, key string) *types.Member {
function ParseCommentTags (line 422) | func ParseCommentTags(t *types.Type, comments []string, prefix string) (...
function extractCommentTags (line 493) | func extractCommentTags(marker string, lines []string) (map[string]strin...
function parseMarkers (line 629) | func parseMarkers(markerComments []string, prefix string) (map[string]an...
function nestMarkers (line 682) | func nestMarkers(markers map[string]any) (map[string]any, error) {
function putNestedValue (line 704) | func putNestedValue(m map[string]any, k []string, v any) error {
function extractArraySubscript (line 780) | func extractArraySubscript(str string) (string, int, bool, error) {
FILE: pkg/generators/markers_test.go
function TestParseCommentTags (line 33) | func TestParseCommentTags(t *testing.T) {
function TestCommentTags_Validate (line 623) | func TestCommentTags_Validate(t *testing.T) {
FILE: pkg/generators/model_names.go
constant tagModelPackage (line 32) | tagModelPackage = "k8s:openapi-model-package"
function extractOpenAPISchemaNamePackage (line 35) | func extractOpenAPISchemaNamePackage(comments []string) (string, error) {
function singularTag (line 43) | func singularTag(tagName string, comments []string) (*gengo.Tag, error) {
type genSchemaName (line 66) | type genSchemaName struct
method Namers (line 87) | func (g *genSchemaName) Namers(c *generator.Context) namer.NameSystems {
method Filter (line 95) | func (g *genSchemaName) Filter(c *generator.Context, t *types.Type) bo...
method isOtherPackage (line 122) | func (g *genSchemaName) isOtherPackage(pkg string) bool {
method Imports (line 132) | func (g *genSchemaName) Imports(c *generator.Context) (imports []strin...
method Init (line 142) | func (g *genSchemaName) Init(c *generator.Context, w io.Writer) error {
method GenerateType (line 146) | func (g *genSchemaName) GenerateType(c *generator.Context, t *types.Ty...
function NewSchemaNameGen (line 75) | func NewSchemaNameGen(outputFilename, targetPackage string, openAPISchem...
function isSchemaNameType (line 106) | func isSchemaNameType(t *types.Type) bool {
FILE: pkg/generators/openapi.go
constant tagName (line 41) | tagName = "k8s:openapi-gen"
constant markerPrefix (line 42) | markerPrefix = "+k8s:validation:"
constant tagOptional (line 43) | tagOptional = "optional"
constant tagRequired (line 44) | tagRequired = "required"
constant tagDefault (line 45) | tagDefault = "default"
constant tagValueTrue (line 49) | tagValueTrue = "true"
constant tagValueFalse (line 50) | tagValueFalse = "false"
function getOpenAPITagValue (line 60) | func getOpenAPITagValue(comments []string) []string {
function getSingleTagsValue (line 64) | func getSingleTagsValue(comments []string, tag string) (string, error) {
function hasOpenAPITagValue (line 75) | func hasOpenAPITagValue(comments []string, value string) bool {
function isOptional (line 88) | func isOptional(m *types.Member) (bool, error) {
function apiTypeFilterFunc (line 106) | func apiTypeFilterFunc(c *generator.Context, t *types.Type) bool {
constant specPackagePath (line 122) | specPackagePath = "k8s.io/kube-openapi/pkg/validation/spec"
constant openAPICommonPackagePath (line 123) | openAPICommonPackagePath = "k8s.io/kube-openapi/pkg/common"
type openAPIGen (line 127) | type openAPIGen struct
method Namers (line 146) | func (g *openAPIGen) Namers(c *generator.Context) namer.NameSystems {
method Imports (line 159) | func (g *openAPIGen) Imports(c *generator.Context) []string {
method Init (line 176) | func (g *openAPIGen) Init(c *generator.Context, w io.Writer) error {
method GenerateType (line 194) | func (g *openAPIGen) GenerateType(c *generator.Context, t *types.Type,...
function newOpenAPIGen (line 134) | func newOpenAPIGen(outputFilename string, targetPackage string) generato...
constant nameTmpl (line 144) | nameTmpl = "schema_$.type|private$"
function argsFromType (line 167) | func argsFromType(t *types.Type) generator.Args {
function getJsonTags (line 204) | func getJsonTags(m *types.Member) []string {
function getReferableName (line 212) | func getReferableName(m *types.Member) string {
function shouldInlineMembers (line 225) | func shouldInlineMembers(m *types.Member) bool {
type openAPITypeWriter (line 230) | type openAPITypeWriter struct
method shouldUseOpenAPIModelName (line 308) | func (g openAPITypeWriter) shouldUseOpenAPIModelName(t *types.Type) bo...
method generateMembers (line 338) | func (g openAPITypeWriter) generateMembers(t *types.Type, required []s...
method generateCall (line 372) | func (g openAPITypeWriter) generateCall(t *types.Type) error {
method generateSchema (line 412) | func (g openAPITypeWriter) generateSchema(s *spec.Schema) error {
method generateValueValidations (line 491) | func (g openAPITypeWriter) generateValueValidations(vs *spec.SchemaPro...
method generate (line 564) | func (g openAPITypeWriter) generate(t *types.Type) error {
method generateStructExtensions (line 731) | func (g openAPITypeWriter) generateStructExtensions(t *types.Type, oth...
method generateMemberExtensions (line 751) | func (g openAPITypeWriter) generateMemberExtensions(m *types.Member, p...
method emitExtensions (line 766) | func (g openAPITypeWriter) emitExtensions(extensions []extension, unio...
method validatePatchTags (line 813) | func (g openAPITypeWriter) validatePatchTags(m *types.Member, parent *...
method generateDefault (line 946) | func (g openAPITypeWriter) generateDefault(comments []string, t *types...
method generateDescription (line 969) | func (g openAPITypeWriter) generateDescription(CommentLines []string) {
method generateProperty (line 1007) | func (g openAPITypeWriter) generateProperty(m *types.Member, parent *t...
method generateSimpleProperty (line 1077) | func (g openAPITypeWriter) generateSimpleProperty(typeString, format s...
method generateReferenceProperty (line 1082) | func (g openAPITypeWriter) generateReferenceProperty(t *types.Type) {
method generateMapProperty (line 1116) | func (g openAPITypeWriter) generateMapProperty(t *types.Type) error {
method generateSliceProperty (line 1160) | func (g openAPITypeWriter) generateSliceProperty(t *types.Type) error {
function newOpenAPITypeWriter (line 238) | func newOpenAPITypeWriter(sw *generator.SnippetWriter, c *generator.Cont...
function methodReturnsValue (line 247) | func methodReturnsValue(mt *types.Type, pkg, name string) bool {
function hasOpenAPIV3DefinitionMethod (line 255) | func hasOpenAPIV3DefinitionMethod(t *types.Type) bool {
function hasOpenAPIDefinitionMethod (line 265) | func hasOpenAPIDefinitionMethod(t *types.Type) bool {
function hasOpenAPIDefinitionMethods (line 275) | func hasOpenAPIDefinitionMethods(t *types.Type) bool {
function hasOpenAPIV3OneOfMethod (line 288) | func hasOpenAPIV3OneOfMethod(t *types.Type) bool {
function hasOpenAPIModelName (line 298) | func hasOpenAPIModelName(t *types.Type) bool {
function typeShortName (line 333) | func typeShortName(t *types.Type) string {
function defaultFromComments (line 829) | func defaultFromComments(comments []string, commentPath string, t *types...
function parseSymbolReference (line 880) | func parseSymbolReference(s, sourcePackage string) (types.Name, bool) {
function implementsCustomUnmarshalling (line 894) | func implementsCustomUnmarshalling(t *types.Type) bool {
function mustEnforceDefault (line 907) | func mustEnforceDefault(t *types.Type, omitEmpty bool) (interface{}, err...
function resolvePtrType (line 1091) | func resolvePtrType(t *types.Type) *types.Type {
function resolveAliasAndPtrType (line 1102) | func resolveAliasAndPtrType(t *types.Type) *types.Type {
FILE: pkg/generators/openapi_test.go
function construct (line 37) | func construct(t *testing.T, cfg *packages.Config, nameSystems namer.Nam...
function testOpenAPITypeWriter (line 49) | func testOpenAPITypeWriter(t *testing.T, cfg *packages.Config) (error, e...
function assertEqual (line 82) | func assertEqual(t *testing.T, got, want string) {
function TestSimple (line 91) | func TestSimple(t *testing.T) {
function TestEmptyProperties (line 413) | func TestEmptyProperties(t *testing.T) {
function TestNestedStruct (line 453) | func TestNestedStruct(t *testing.T) {
function TestNestedStructPointer (line 513) | func TestNestedStructPointer(t *testing.T) {
function TestEmbeddedStruct (line 573) | func TestEmbeddedStruct(t *testing.T) {
function TestSingleEmbeddedStruct (line 633) | func TestSingleEmbeddedStruct(t *testing.T) {
function TestEmbeddedInlineStruct (line 695) | func TestEmbeddedInlineStruct(t *testing.T) {
function TestEmbeddedInlineStructPointer (line 754) | func TestEmbeddedInlineStructPointer(t *testing.T) {
function TestEmbeddedInlineStructWithEmptyJSONTag (line 813) | func TestEmbeddedInlineStructWithEmptyJSONTag(t *testing.T) {
function TestNestedMapString (line 872) | func TestNestedMapString(t *testing.T) {
function TestNestedMapInt (line 941) | func TestNestedMapInt(t *testing.T) {
function TestNestedMapBoolean (line 1010) | func TestNestedMapBoolean(t *testing.T) {
function TestFailingSample1 (line 1079) | func TestFailingSample1(t *testing.T) {
function TestFailingSample2 (line 1108) | func TestFailingSample2(t *testing.T) {
function TestFailingDefaultEnforced (line 1137) | func TestFailingDefaultEnforced(t *testing.T) {
function TestCustomDef (line 1208) | func TestCustomDef(t *testing.T) {
function TestCustomDefV3 (line 1258) | func TestCustomDefV3(t *testing.T) {
function TestCustomDefV2AndV3 (line 1308) | func TestCustomDefV2AndV3(t *testing.T) {
function TestCustomDefs (line 1369) | func TestCustomDefs(t *testing.T) {
function TestCustomDefsV3 (line 1413) | func TestCustomDefsV3(t *testing.T) {
function TestV3OneOfTypes (line 1478) | func TestV3OneOfTypes(t *testing.T) {
function TestPointer (line 1531) | func TestPointer(t *testing.T) {
function TestNestedLists (line 1627) | func TestNestedLists(t *testing.T) {
function TestNestListOfMaps (line 1700) | func TestNestListOfMaps(t *testing.T) {
function TestExtensions (line 1781) | func TestExtensions(t *testing.T) {
function TestUnion (line 1887) | func TestUnion(t *testing.T) {
function TestEnumAlias (line 1982) | func TestEnumAlias(t *testing.T) {
function TestEnum (line 2062) | func TestEnum(t *testing.T) {
function TestSymbolReference (line 2183) | func TestSymbolReference(t *testing.T) {
function TestMustEnforceDefaultStruct (line 2295) | func TestMustEnforceDefaultStruct(t *testing.T) {
function TestMarkerComments (line 2427) | func TestMarkerComments(t *testing.T) {
function TestCELMarkerComments (line 2566) | func TestCELMarkerComments(t *testing.T) {
function TestMultilineCELMarkerComments (line 2647) | func TestMultilineCELMarkerComments(t *testing.T) {
function TestRequired (line 2732) | func TestRequired(t *testing.T) {
function TestMarkerCommentsCustomDefsV3 (line 2872) | func TestMarkerCommentsCustomDefsV3(t *testing.T) {
function TestMarkerCommentsV3OneOfTypes (line 2938) | func TestMarkerCommentsV3OneOfTypes(t *testing.T) {
function TestNestedMarkers (line 2990) | func TestNestedMarkers(t *testing.T) {
function TestShouldInlineMembers (line 3165) | func TestShouldInlineMembers(t *testing.T) {
FILE: pkg/generators/rules/idl_tag.go
constant ListTypeIDLTag (line 8) | ListTypeIDLTag = "listType"
type ListTypeMissing (line 12) | type ListTypeMissing struct
method Name (line 15) | func (l *ListTypeMissing) Name() string {
method Validate (line 22) | func (l *ListTypeMissing) Validate(t *types.Type) ([]string, error) {
function hasNamedMember (line 48) | func hasNamedMember(t *types.Type, name string) bool {
FILE: pkg/generators/rules/idl_tag_test.go
function TestListTypeMissing (line 10) | func TestListTypeMissing(t *testing.T) {
FILE: pkg/generators/rules/list_type_streaming_tags.go
type StreamingListTypeFieldOrder (line 27) | type StreamingListTypeFieldOrder struct
method Name (line 29) | func (l *StreamingListTypeFieldOrder) Name() string {
method Validate (line 32) | func (l *StreamingListTypeFieldOrder) Validate(t *types.Type) ([]strin...
type StreamingListTypeJSONTags (line 51) | type StreamingListTypeJSONTags struct
method Name (line 53) | func (l *StreamingListTypeJSONTags) Name() string {
method Validate (line 57) | func (l *StreamingListTypeJSONTags) Validate(t *types.Type) ([]string,...
type StreamingListTypeProtoTags (line 90) | type StreamingListTypeProtoTags struct
method Name (line 92) | func (l *StreamingListTypeProtoTags) Name() string {
method Validate (line 95) | func (l *StreamingListTypeProtoTags) Validate(t *types.Type) ([]string...
function isListType (line 119) | func isListType(t *types.Type) bool {
FILE: pkg/generators/rules/list_type_streaming_tags_test.go
function TestStreamingListTypeFieldOrder (line 26) | func TestStreamingListTypeFieldOrder(t *testing.T) {
function TestStreamingListTypeJSONTags (line 112) | func TestStreamingListTypeJSONTags(t *testing.T) {
function TestStreamingListTypeProtoTags (line 271) | func TestStreamingListTypeProtoTags(t *testing.T) {
FILE: pkg/generators/rules/names_match.go
type NamesMatch (line 74) | type NamesMatch struct
method Name (line 77) | func (n *NamesMatch) Name() string {
method Validate (line 84) | func (n *NamesMatch) Validate(t *types.Type) ([]string, error) {
function nameIsOkay (line 111) | func nameIsOkay(member types.Member, jsonName string) bool {
function namesMatch (line 138) | func namesMatch(goName, jsonName string) bool {
function isCapital (line 169) | func isCapital(b byte) bool {
function isAllowedName (line 175) | func isAllowedName(name string) bool {
FILE: pkg/generators/rules/names_match_test.go
function TestNamesMatch (line 26) | func TestNamesMatch(t *testing.T) {
function TestRuleName (line 443) | func TestRuleName(t *testing.T) {
FILE: pkg/generators/rules/omitempty_match_case.go
type OmitEmptyMatchCase (line 28) | type OmitEmptyMatchCase struct
method Name (line 30) | func (n *OmitEmptyMatchCase) Name() string {
method Validate (line 34) | func (n *OmitEmptyMatchCase) Validate(t *types.Type) ([]string, error) {
FILE: pkg/generators/rules/omitempty_match_case_test.go
function TestOmitEmptyMatchCase (line 26) | func TestOmitEmptyMatchCase(t *testing.T) {
FILE: pkg/generators/union.go
constant tagUnionMember (line 27) | tagUnionMember = "union"
constant tagUnionDeprecated (line 28) | tagUnionDeprecated = "unionDeprecated"
constant tagUnionDiscriminator (line 29) | tagUnionDiscriminator = "unionDiscriminator"
type union (line 31) | type union struct
method emit (line 37) | func (u *union) emit(g openAPITypeWriter) {
method setDiscriminator (line 60) | func (u *union) setDiscriminator(value string) []error {
method addMember (line 70) | func (u *union) addMember(jsonName, variableName string) {
method isValid (line 78) | func (u *union) isValid() []error {
function parseUnions (line 103) | func parseUnions(t *types.Type) ([]union, []error) {
function parseEmbeddedUnion (line 123) | func parseEmbeddedUnion(t *types.Type) ([]union, []error) {
function parseUnionStruct (line 143) | func parseUnionStruct(t *types.Type) (*union, []error) {
function parseUnionMembers (line 178) | func parseUnionMembers(t *types.Type) (*union, []error) {
FILE: pkg/handler/default_pruning.go
function PruneDefaults (line 24) | func PruneDefaults(definitions spec.Definitions) spec.Definitions {
function PruneDefaultsSchema (line 44) | func PruneDefaultsSchema(schema *spec.Schema) *spec.Schema {
FILE: pkg/handler/default_pruning_test.go
function TestDefaultPruning (line 29) | func TestDefaultPruning(t *testing.T) {
FILE: pkg/handler/handler.go
constant subTypeProtobufDeprecated (line 43) | subTypeProtobufDeprecated = "com.github.proto-openapi.spec.v2@v1.0+proto...
constant subTypeProtobuf (line 44) | subTypeProtobuf = "com.github.proto-openapi.spec.v2.v1.0+proto...
constant subTypeJSON (line 45) | subTypeJSON = "json"
function computeETag (line 48) | func computeETag(data []byte) string {
type timedSpec (line 55) | type timedSpec struct
type OpenAPIService (line 62) | type OpenAPIService struct
method UpdateSpec (line 102) | func (o *OpenAPIService) UpdateSpec(swagger *spec.Swagger) error {
method UpdateSpecLazy (line 107) | func (o *OpenAPIService) UpdateSpecLazy(swagger cached.Value[*spec.Swa...
method RegisterOpenAPIVersionedService (line 129) | func (o *OpenAPIService) RegisterOpenAPIVersionedService(servePath str...
function NewOpenAPIService (line 69) | func NewOpenAPIService(swagger *spec.Swagger) *OpenAPIService {
function NewOpenAPIServiceLazy (line 74) | func NewOpenAPIServiceLazy(swagger cached.Value[*spec.Swagger]) *OpenAPI...
function ToProtoBinary (line 111) | func ToProtoBinary(json []byte) ([]byte, error) {
function RegisterOpenAPIVersionedService (line 122) | func RegisterOpenAPIVersionedService(spec *spec.Swagger, servePath strin...
function BuildAndRegisterOpenAPIVersionedService (line 188) | func BuildAndRegisterOpenAPIVersionedService(servePath string, webServic...
function BuildAndRegisterOpenAPIVersionedServiceFromRoutes (line 194) | func BuildAndRegisterOpenAPIVersionedServiceFromRoutes(servePath string,...
FILE: pkg/handler/handler_test.go
function TestRegisterOpenAPIVersionedService (line 25) | func TestRegisterOpenAPIVersionedService(t *testing.T) {
function getJSONBodyOrDie (line 120) | func getJSONBodyOrDie(server *httptest.Server) []byte {
function getProtoBodyOrDie (line 124) | func getProtoBodyOrDie(server *httptest.Server) []byte {
function getBodyOrDie (line 128) | func getBodyOrDie(server *httptest.Server, acceptHeader string) []byte {
function normalizeSwaggerOrDie (line 148) | func normalizeSwaggerOrDie(j []byte) []byte {
function TestUpdateSpecLazy (line 161) | func TestUpdateSpecLazy(t *testing.T) {
function TestToProtoBinary (line 197) | func TestToProtoBinary(t *testing.T) {
function TestConcurrentReadStaleCache (line 208) | func TestConcurrentReadStaleCache(t *testing.T) {
FILE: pkg/handler3/handler.go
constant subTypeProtobufDeprecated (line 44) | subTypeProtobufDeprecated = "com.github.proto-openapi.spec.v3@v1.0+proto...
constant subTypeProtobuf (line 45) | subTypeProtobuf = "com.github.proto-openapi.spec.v3.v1.0+proto...
constant subTypeJSON (line 46) | subTypeJSON = "json"
type OpenAPIV3Discovery (line 51) | type OpenAPIV3Discovery struct
type OpenAPIV3DiscoveryGroupVersion (line 57) | type OpenAPIV3DiscoveryGroupVersion struct
function ToV3ProtoBinary (line 62) | func ToV3ProtoBinary(json []byte) ([]byte, error) {
type timedSpec (line 70) | type timedSpec struct
type openAPIV3Group (line 76) | type openAPIV3Group struct
method UpdateSpec (line 107) | func (o *openAPIV3Group) UpdateSpec(openapi cached.Value[*spec3.OpenAP...
function newOpenAPIV3Group (line 82) | func newOpenAPIV3Group() *openAPIV3Group {
type OpenAPIService (line 113) | type OpenAPIService struct
method buildDiscoveryCacheLocked (line 145) | func (o *OpenAPIService) buildDiscoveryCacheLocked() cached.Value[time...
method getSingleGroupBytes (line 168) | func (o *OpenAPIService) getSingleGroupBytes(getType string, group str...
method UpdateGroupVersionLazy (line 188) | func (o *OpenAPIService) UpdateGroupVersionLazy(group string, openapi ...
method UpdateGroupVersion (line 199) | func (o *OpenAPIService) UpdateGroupVersion(group string, openapi *spe...
method DeleteGroupVersion (line 203) | func (o *OpenAPIService) DeleteGroupVersion(group string) {
method HandleDiscovery (line 211) | func (o *OpenAPIService) HandleDiscovery(w http.ResponseWriter, r *htt...
method HandleGroupVersion (line 223) | func (o *OpenAPIService) HandleGroupVersion(w http.ResponseWriter, r *...
method RegisterOpenAPIV3VersionedService (line 291) | func (o *OpenAPIService) RegisterOpenAPIV3VersionedService(servePath s...
function computeETag (line 121) | func computeETag(data []byte) string {
function constructServerRelativeURL (line 128) | func constructServerRelativeURL(gvString, etag string) string {
function NewOpenAPIService (line 137) | func NewOpenAPIService() *OpenAPIService {
FILE: pkg/handler3/handler_test.go
function TestRegisterOpenAPIVersionedService (line 44) | func TestRegisterOpenAPIVersionedService(t *testing.T) {
function TestCacheBusting (line 288) | func TestCacheBusting(t *testing.T) {
function openAPIOrDie (line 437) | func openAPIOrDie(name string) *spec3.OpenAPI {
function getDiscovery (line 452) | func getDiscovery(server *httptest.Server, path string) (*OpenAPIV3Disco...
function TestUpdateGroupVersion (line 478) | func TestUpdateGroupVersion(t *testing.T) {
FILE: pkg/idl/doc.go
type ListType (line 69) | type ListType
type ListMapKey (line 87) | type ListMapKey
type MapType (line 113) | type MapType
type OpenAPIGen (line 116) | type OpenAPIGen
type Optional (line 131) | type Optional
type PatchMergeKey (line 134) | type PatchMergeKey
type PatchStrategy (line 137) | type PatchStrategy
type StructType (line 163) | type StructType
type Union (line 166) | type Union
FILE: pkg/idl/listtype_test.go
function ExampleListType_map (line 26) | func ExampleListType_map() {
function ExampleListType_set (line 41) | func ExampleListType_set() {
function ExampleListType_atomic (line 50) | func ExampleListType_atomic() {
FILE: pkg/idl/maptype_test.go
function ExampleMapType_atomic (line 25) | func ExampleMapType_atomic() {
FILE: pkg/idl/structtype_test.go
function ExampleStructType_atomic (line 25) | func ExampleStructType_atomic() {
FILE: pkg/internal/serialization.go
function DeterministicMarshal (line 26) | func DeterministicMarshal(in any) ([]byte, error) {
function JSONRefFromMap (line 31) | func JSONRefFromMap(jsonRef *jsonreference.Ref, v map[string]interface{}...
function SanitizeExtensions (line 50) | func SanitizeExtensions(e map[string]interface{}) map[string]interface{} {
function IsExtensionKey (line 63) | func IsExtensionKey(k string) bool {
FILE: pkg/internal/serialization_test.go
function TestJSONRefFromMap (line 25) | func TestJSONRefFromMap(t *testing.T) {
function TestSanitizeExtensions (line 60) | func TestSanitizeExtensions(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal.go
type MarshalOptions (line 16) | type MarshalOptions struct
method Marshal (line 65) | func (mo MarshalOptions) Marshal(eo EncodeOptions, in any) (out []byte...
method MarshalFull (line 77) | func (mo MarshalOptions) MarshalFull(eo EncodeOptions, out io.Writer, ...
method MarshalNext (line 202) | func (mo MarshalOptions) MarshalNext(out *Encoder, in any) error {
function Marshal (line 52) | func Marshal(in any) (out []byte, err error) {
function MarshalFull (line 58) | func MarshalFull(out io.Writer, in any) error {
type UnmarshalOptions (line 233) | type UnmarshalOptions struct
method Unmarshal (line 272) | func (uo UnmarshalOptions) Unmarshal(do DecodeOptions, in []byte, out ...
method UnmarshalFull (line 283) | func (uo UnmarshalOptions) UnmarshalFull(do DecodeOptions, in io.Reade...
method unmarshalFull (line 288) | func (uo UnmarshalOptions) unmarshalFull(in *Decoder, out any) error {
method UnmarshalNext (line 444) | func (uo UnmarshalOptions) UnmarshalNext(in *Decoder, out any) error {
function Unmarshal (line 258) | func Unmarshal(in []byte, out any) error {
function UnmarshalFull (line 264) | func UnmarshalFull(in io.Reader, out any) error {
type addressableValue (line 480) | type addressableValue struct
function newAddressableValue (line 483) | func newAddressableValue(t reflect.Type) addressableValue {
type arshaler (line 493) | type arshaler struct
function lookupArshaler (line 501) | func lookupArshaler(t reflect.Type) *arshaler {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_any.go
function marshalValueAny (line 14) | func marshalValueAny(mo MarshalOptions, enc *Encoder, val any) error {
function unmarshalValueAny (line 39) | func unmarshalValueAny(uo UnmarshalOptions, dec *Decoder) (any, error) {
function marshalObjectAny (line 73) | func marshalObjectAny(mo MarshalOptions, enc *Encoder, obj map[string]an...
function unmarshalObjectAny (line 135) | func unmarshalObjectAny(uo UnmarshalOptions, dec *Decoder) (map[string]a...
function marshalArrayAny (line 179) | func marshalArrayAny(mo MarshalOptions, enc *Encoder, arr []any) error {
function unmarshalArrayAny (line 214) | func unmarshalArrayAny(uo UnmarshalOptions, dec *Decoder) ([]any, error) {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_default.go
constant optimizeCommon (line 24) | optimizeCommon = true
constant startDetectingCyclesAfter (line 39) | startDetectingCyclesAfter = 1000
type seenPointers (line 41) | type seenPointers
method visit (line 50) | func (m *seenPointers) visit(v reflect.Value) error {
method leave (line 61) | func (m *seenPointers) leave(v reflect.Value) {
type typedPointer (line 43) | type typedPointer struct
function makeDefaultArshaler (line 66) | func makeDefaultArshaler(t reflect.Type) *arshaler {
function makeBoolArshaler (line 103) | func makeBoolArshaler(t reflect.Type) *arshaler {
function makeStringArshaler (line 149) | func makeStringArshaler(t reflect.Type) *arshaler {
function makeBytesArshaler (line 208) | func makeBytesArshaler(t reflect.Type, fncs *arshaler) *arshaler {
function makeIntArshaler (line 323) | func makeIntArshaler(t reflect.Type) *arshaler {
function makeUintArshaler (line 397) | func makeUintArshaler(t reflect.Type) *arshaler {
function makeFloatArshaler (line 462) | func makeFloatArshaler(t reflect.Type) *arshaler {
function makeMapArshaler (line 553) | func makeMapArshaler(t reflect.Type) *arshaler {
function mapKeyWithUniqueRepresentation (line 811) | func mapKeyWithUniqueRepresentation(k reflect.Kind, allowInvalidUTF8 boo...
function makeStructArshaler (line 828) | func makeStructArshaler(t reflect.Type) *arshaler {
method fieldByIndex (line 1087) | func (va addressableValue) fieldByIndex(index []int, mayAlloc bool) addr...
method indirect (line 1098) | func (va addressableValue) indirect(mayAlloc bool) addressableValue {
function makeSliceArshaler (line 1111) | func makeSliceArshaler(t reflect.Type) *arshaler {
function makeArrayArshaler (line 1235) | func makeArrayArshaler(t reflect.Type) *arshaler {
function makePointerArshaler (line 1314) | func makePointerArshaler(t reflect.Type) *arshaler {
function makeInterfaceArshaler (line 1367) | func makeInterfaceArshaler(t reflect.Type) *arshaler {
function isAnyType (line 1463) | func isAnyType(t reflect.Type) bool {
function makeInvalidArshaler (line 1471) | func makeInvalidArshaler(t reflect.Type) *arshaler {
function newInvalidFormatError (line 1482) | func newInvalidFormatError(action string, t reflect.Type, format string)...
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_funcs.go
constant SkipFunc (line 20) | SkipFunc = jsonError("skip function")
function NewMarshalers (line 38) | func NewMarshalers(ms ...*Marshalers) *Marshalers {
function NewUnmarshalers (line 58) | func NewUnmarshalers(us ...*Unmarshalers) *Unmarshalers {
type typedArshalers (line 64) | type typedArshalers struct
type typedArshaler (line 83) | type typedArshaler struct
function newMarshalers (line 89) | func newMarshalers(ms ...*Marshalers) *Marshalers { return newType...
function newUnmarshalers (line 90) | func newUnmarshalers(us ...*Unmarshalers) *Unmarshalers { return newType...
function newTypedArshalers (line 91) | func newTypedArshalers[Options, Coder any](as ...*typedArshalers[Options...
method lookup (line 105) | func (a *typedArshalers[Options, Coder]) lookup(fnc func(Options, *Coder...
function MarshalFuncV1 (line 159) | func MarshalFuncV1[T any](fn func(T) ([]byte, error)) *Marshalers {
function MarshalFuncV2 (line 193) | func MarshalFuncV2[T any](fn func(MarshalOptions, *Encoder, T) error) *M...
function UnmarshalFuncV1 (line 231) | func UnmarshalFuncV1[T any](fn func([]byte, T) error) *Unmarshalers {
function UnmarshalFuncV2 (line 264) | func UnmarshalFuncV2[T any](fn func(UnmarshalOptions, *Decoder, T) error...
function assertCastableTo (line 307) | func assertCastableTo(to reflect.Type, marshal bool) {
function castableTo (line 336) | func castableTo(from, to reflect.Type) bool {
method castTo (line 360) | func (va addressableValue) castTo(to reflect.Type) reflect.Value {
function castableToFromAny (line 373) | func castableToFromAny(to reflect.Type) bool {
function wrapSkipFunc (line 382) | func wrapSkipFunc(err error, what string) error {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_inlined.go
function marshalInlinedFallbackAll (line 29) | func marshalInlinedFallbackAll(mo MarshalOptions, enc *Encoder, va addre...
function unmarshalInlinedFallbackNext (line 154) | func unmarshalInlinedFallbackNext(uo UnmarshalOptions, dec *Decoder, va ...
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_methods.go
type MarshalerV1 (line 29) | type MarshalerV1 interface
type MarshalerV2 (line 42) | type MarshalerV2 interface
type UnmarshalerV1 (line 60) | type UnmarshalerV1 interface
type UnmarshalerV2 (line 76) | type UnmarshalerV2 interface
function makeMethodArshaler (line 83) | func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
function implementsWhich (line 211) | func implementsWhich(t reflect.Type, ifaceTypes ...reflect.Type) (which ...
method addrWhen (line 224) | func (va addressableValue) addrWhen(addr bool) reflect.Value {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_test.go
type testName (line 27) | type testName struct
function name (line 32) | func name(s string) (t testName) {
type pc (line 38) | type pc
method String (line 40) | func (pc pc) String() string {
type namedAny (line 50) | type namedAny
type namedBool (line 51) | type namedBool
type namedString (line 52) | type namedString
type namedBytes (line 53) | type namedBytes
type namedInt64 (line 54) | type namedInt64
type namedUint64 (line 55) | type namedUint64
type namedFloat64 (line 56) | type namedFloat64
type namedByte (line 57) | type namedByte
type recursiveMap (line 59) | type recursiveMap
type recursiveSlice (line 60) | type recursiveSlice
type recursivePointer (line 61) | type recursivePointer struct
type structEmpty (line 63) | type structEmpty struct
type structConflicting (line 64) | type structConflicting struct
type structNoneExported (line 68) | type structNoneExported struct
type structUnexportedIgnored (line 71) | type structUnexportedIgnored struct
type structMalformedTag (line 74) | type structMalformedTag struct
type structUnexportedTag (line 77) | type structUnexportedTag struct
type structUnexportedEmbedded (line 80) | type structUnexportedEmbedded struct
type structIgnoredUnexportedEmbedded (line 83) | type structIgnoredUnexportedEmbedded struct
type structWeirdNames (line 86) | type structWeirdNames struct
type structNoCase (line 91) | type structNoCase struct
type structScalars (line 96) | type structScalars struct
type structSlices (line 107) | type structSlices struct
type structMaps (line 118) | type structMaps struct
type structAll (line 129) | type structAll struct
type structStringifiedAll (line 145) | type structStringifiedAll struct
type structOmitZeroAll (line 161) | type structOmitZeroAll struct
type structOmitZeroMethodAll (line 177) | type structOmitZeroMethodAll struct
type structOmitZeroMethodInterfaceAll (line 191) | type structOmitZeroMethodInterfaceAll struct
type structOmitEmptyAll (line 199) | type structOmitEmptyAll struct
type structOmitZeroEmptyAll (line 231) | type structOmitZeroEmptyAll struct
type structFormatBytes (line 244) | type structFormatBytes struct
type structFormatFloats (line 252) | type structFormatFloats struct
type structFormatMaps (line 256) | type structFormatMaps struct
type structFormatSlices (line 260) | type structFormatSlices struct
type structFormatInvalid (line 264) | type structFormatInvalid struct
type structTimeFormat (line 277) | type structTimeFormat struct
type structInlined (line 297) | type structInlined struct
type structInlinedL1 (line 301) | type structInlinedL1 struct
type structInlinedL2 (line 305) | type structInlinedL2 struct
type StructEmbed1 (line 306) | type StructEmbed1 struct
type StructEmbed2 (line 307) | type StructEmbed2 struct
type structUnknownRawValue (line 308) | type structUnknownRawValue struct
type structInlineRawValue (line 313) | type structInlineRawValue struct
type structInlinePointerRawValue (line 318) | type structInlinePointerRawValue struct
type structInlinePointerInlineRawValue (line 323) | type structInlinePointerInlineRawValue struct
type structInlineInlinePointerRawValue (line 329) | type structInlineInlinePointerRawValue struct
type structInlineMapStringAny (line 334) | type structInlineMapStringAny struct
type structInlinePointerMapStringAny (line 339) | type structInlinePointerMapStringAny struct
type structInlinePointerInlineMapStringAny (line 344) | type structInlinePointerInlineMapStringAny struct
type structInlineInlinePointerMapStringAny (line 350) | type structInlineInlinePointerMapStringAny struct
type structInlineMapStringInt (line 355) | type structInlineMapStringInt struct
type structNoCaseInlineRawValue (line 358) | type structNoCaseInlineRawValue struct
type structNoCaseInlineMapStringAny (line 365) | type structNoCaseInlineMapStringAny struct
type allMethods (line 373) | type allMethods struct
method MarshalNextJSON (line 454) | func (p *allMethods) MarshalNextJSON(mo MarshalOptions, enc *Encoder) ...
method MarshalJSON (line 460) | func (p *allMethods) MarshalJSON() ([]byte, error) {
method MarshalText (line 466) | func (p *allMethods) MarshalText() ([]byte, error) {
method UnmarshalNextJSON (line 473) | func (p *allMethods) UnmarshalNextJSON(uo UnmarshalOptions, dec *Decod...
method UnmarshalJSON (line 479) | func (p *allMethods) UnmarshalJSON(val []byte) error {
method UnmarshalText (line 484) | func (p *allMethods) UnmarshalText(val []byte) error {
type allMethodsExceptJSONv2 (line 377) | type allMethodsExceptJSONv2 struct
type allMethodsExceptJSONv1 (line 382) | type allMethodsExceptJSONv1 struct
type allMethodsExceptText (line 387) | type allMethodsExceptText struct
type onlyMethodJSONv2 (line 392) | type onlyMethodJSONv2 struct
type onlyMethodJSONv1 (line 399) | type onlyMethodJSONv1 struct
type onlyMethodText (line 406) | type onlyMethodText struct
type structMethodJSONv2 (line 414) | type structMethodJSONv2 struct
method MarshalNextJSON (line 490) | func (s structMethodJSONv2) MarshalNextJSON(mo MarshalOptions, enc *En...
method UnmarshalNextJSON (line 493) | func (s *structMethodJSONv2) UnmarshalNextJSON(uo UnmarshalOptions, de...
type structMethodJSONv1 (line 415) | type structMethodJSONv1 struct
method MarshalJSON (line 505) | func (s structMethodJSONv1) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 508) | func (s *structMethodJSONv1) UnmarshalJSON(b []byte) error {
type structMethodText (line 416) | type structMethodText struct
method MarshalText (line 517) | func (s structMethodText) MarshalText() ([]byte, error) {
method UnmarshalText (line 520) | func (s *structMethodText) UnmarshalText(b []byte) error {
type marshalJSONv2Func (line 418) | type marshalJSONv2Func
method MarshalNextJSON (line 525) | func (f marshalJSONv2Func) MarshalNextJSON(mo MarshalOptions, enc *Enc...
type marshalJSONv1Func (line 419) | type marshalJSONv1Func
method MarshalJSON (line 528) | func (f marshalJSONv1Func) MarshalJSON() ([]byte, error) {
type marshalTextFunc (line 420) | type marshalTextFunc
method MarshalText (line 531) | func (f marshalTextFunc) MarshalText() ([]byte, error) {
type unmarshalJSONv2Func (line 421) | type unmarshalJSONv2Func
method UnmarshalNextJSON (line 534) | func (f unmarshalJSONv2Func) UnmarshalNextJSON(uo UnmarshalOptions, de...
type unmarshalJSONv1Func (line 422) | type unmarshalJSONv1Func
method UnmarshalJSON (line 537) | func (f unmarshalJSONv1Func) UnmarshalJSON(b []byte) error {
type unmarshalTextFunc (line 423) | type unmarshalTextFunc
method UnmarshalText (line 540) | func (f unmarshalTextFunc) UnmarshalText(b []byte) error {
type nocaseString (line 425) | type nocaseString
method MarshalText (line 544) | func (k nocaseString) MarshalText() ([]byte, error) {
method UnmarshalText (line 547) | func (k *nocaseString) UnmarshalText(b []byte) error {
type stringMarshalEmpty (line 427) | type stringMarshalEmpty
method MarshalJSON (line 552) | func (stringMarshalEmpty) MarshalJSON() ([]byte, error) { return []...
type stringMarshalNonEmpty (line 428) | type stringMarshalNonEmpty
method MarshalJSON (line 553) | func (stringMarshalNonEmpty) MarshalJSON() ([]byte, error) { return []...
type bytesMarshalEmpty (line 429) | type bytesMarshalEmpty
method MarshalJSON (line 554) | func (bytesMarshalEmpty) MarshalJSON() ([]byte, error) { return []...
type bytesMarshalNonEmpty (line 430) | type bytesMarshalNonEmpty
method MarshalJSON (line 555) | func (bytesMarshalNonEmpty) MarshalJSON() ([]byte, error) { return []...
type mapMarshalEmpty (line 431) | type mapMarshalEmpty
method MarshalJSON (line 556) | func (mapMarshalEmpty) MarshalJSON() ([]byte, error) { return []...
type mapMarshalNonEmpty (line 432) | type mapMarshalNonEmpty
method MarshalJSON (line 557) | func (mapMarshalNonEmpty) MarshalJSON() ([]byte, error) { return []...
type sliceMarshalEmpty (line 433) | type sliceMarshalEmpty
method MarshalJSON (line 558) | func (sliceMarshalEmpty) MarshalJSON() ([]byte, error) { return []...
type sliceMarshalNonEmpty (line 434) | type sliceMarshalNonEmpty
method MarshalJSON (line 559) | func (sliceMarshalNonEmpty) MarshalJSON() ([]byte, error) { return []...
type valueAlwaysZero (line 436) | type valueAlwaysZero
method IsZero (line 561) | func (valueAlwaysZero) IsZero() bool { return true }
type valueNeverZero (line 437) | type valueNeverZero
method IsZero (line 562) | func (valueNeverZero) IsZero() bool { return false }
type pointerAlwaysZero (line 438) | type pointerAlwaysZero
method IsZero (line 563) | func (*pointerAlwaysZero) IsZero() bool { return true }
type pointerNeverZero (line 439) | type pointerNeverZero
method IsZero (line 564) | func (*pointerNeverZero) IsZero() bool { return false }
type valueStringer (line 441) | type valueStringer struct
method String (line 566) | func (valueStringer) String() string { return "" }
type pointerStringer (line 442) | type pointerStringer struct
method String (line 567) | func (*pointerStringer) String() string { return "" }
type cyclicA (line 444) | type cyclicA struct
type cyclicB (line 448) | type cyclicB struct
function addr (line 618) | func addr[T any](v T) *T {
function mustParseTime (line 622) | func mustParseTime(layout, value string) time.Time {
function TestMarshal (line 630) | func TestMarshal(t *testing.T) {
function TestUnmarshal (line 3699) | func TestUnmarshal(t *testing.T) {
function TestMarshalInvalidNamespace (line 7664) | func TestMarshalInvalidNamespace(t *testing.T) {
function TestUnmarshalInvalidNamespace (line 7692) | func TestUnmarshalInvalidNamespace(t *testing.T) {
function TestUnmarshalReuse (line 7716) | func TestUnmarshalReuse(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/arshal_time.go
function makeTimeArshaler (line 20) | func makeTimeArshaler(fncs *arshaler, t reflect.Type) *arshaler {
function checkTimeFormat (line 191) | func checkTimeFormat(format string) (string, bool, error) {
function parseDec2 (line 239) | func parseDec2(b []byte) byte {
FILE: pkg/internal/third_party/go-json-experiment/json/bench_test.go
type bytesBuffer (line 25) | type bytesBuffer struct
type textArshaler (line 168) | type textArshaler struct
method MarshalText (line 170) | func (*textArshaler) MarshalText() ([]byte, error) {
method UnmarshalText (line 173) | func (*textArshaler) UnmarshalText(b []byte) error {
type jsonArshalerV1 (line 180) | type jsonArshalerV1 struct
method MarshalJSON (line 182) | func (*jsonArshalerV1) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 185) | func (*jsonArshalerV1) UnmarshalJSON(b []byte) error {
type jsonArshalerV2 (line 192) | type jsonArshalerV2 struct
method MarshalNextJSON (line 194) | func (*jsonArshalerV2) MarshalNextJSON(opts MarshalOptions, enc *Encod...
method UnmarshalNextJSON (line 197) | func (*jsonArshalerV2) UnmarshalNextJSON(opts UnmarshalOptions, dec *D...
function TestBenchmarkUnmarshal (line 205) | func TestBenchmarkUnmarshal(t *testing.T) { runUnmarshal(t) }
function BenchmarkUnmarshal (line 206) | func BenchmarkUnmarshal(b *testing.B) { runUnmarshal(b) }
function runUnmarshal (line 208) | func runUnmarshal(tb testing.TB) {
function TestBenchmarkMarshal (line 245) | func TestBenchmarkMarshal(t *testing.T) { runMarshal(t) }
function BenchmarkMarshal (line 246) | func BenchmarkMarshal(b *testing.B) { runMarshal(b) }
function runMarshal (line 248) | func runMarshal(tb testing.TB) {
function TestBenchmarkTestdata (line 296) | func TestBenchmarkTestdata(t *testing.T) { runAllTestdata(t) }
function BenchmarkTestdata (line 297) | func BenchmarkTestdata(b *testing.B) { runAllTestdata(b) }
function runAllTestdata (line 299) | func runAllTestdata(tb testing.TB) {
function mustUnmarshalValue (line 333) | func mustUnmarshalValue(t testing.TB, data []byte, newValue func() any) ...
function runArshal (line 341) | func runArshal(t testing.TB, arshalName string, newValue func() any, dat...
function mustDecodeTokens (line 368) | func mustDecodeTokens(t testing.TB, data []byte) []Token {
function runCode (line 394) | func runCode(t testing.TB, codeName, typeName, modeName string, buffer, ...
function runEncode (line 403) | func runEncode(t testing.TB, typeName, modeName string, buffer, data []b...
function runDecode (line 442) | func runDecode(t testing.TB, typeName, modeName string, buffer, data []b...
function TestBenchmarkSlowStreamingDecode (line 503) | func TestBenchmarkSlowStreamingDecode(t *testing.T) { runAllSlowStreamin...
function BenchmarkSlowStreamingDecode (line 504) | func BenchmarkSlowStreamingDecode(b *testing.B) { runAllSlowStreamin...
function runAllSlowStreamingDecode (line 506) | func runAllSlowStreamingDecode(tb testing.TB) {
function runSlowStreamingDecode (line 520) | func runSlowStreamingDecode(t testing.TB, typeName string, data []byte) {
function TestBenchmarkRawValue (line 554) | func TestBenchmarkRawValue(t *testing.T) { runRawValue(t) }
function BenchmarkRawValue (line 555) | func BenchmarkRawValue(b *testing.B) { runRawValue(b) }
function runRawValue (line 557) | func runRawValue(tb testing.TB) {
function runTestOrBench (line 599) | func runTestOrBench(tb testing.TB, name string, numBytes int64, run func...
FILE: pkg/internal/third_party/go-json-experiment/json/coder_test.go
type tokOrVal (line 24) | type tokOrVal interface
type coderTestdataEntry (line 26) | type coderTestdataEntry struct
function TestCoderInterleaved (line 416) | func TestCoderInterleaved(t *testing.T) {
function testCoderInterleaved (line 427) | func testCoderInterleaved(t *testing.T, where pc, modeName string, td co...
function TestCoderStackPointer (line 487) | func TestCoderStackPointer(t *testing.T) {
function TestCoderBufferGrowth (line 581) | func TestCoderBufferGrowth(t *testing.T) {
type ReaderFunc (line 634) | type ReaderFunc
method Read (line 636) | func (f ReaderFunc) Read(b []byte) (int, error) { return f(b) }
type WriterFunc (line 638) | type WriterFunc
method Write (line 640) | func (f WriterFunc) Write(b []byte) (int, error) { return f(b) }
type FaultyBuffer (line 645) | type FaultyBuffer struct
method Read (line 662) | func (p *FaultyBuffer) Read(b []byte) (int, error) {
method Write (line 671) | func (p *FaultyBuffer) Write(b []byte) (int, error) {
method mayTruncate (line 681) | func (p *FaultyBuffer) mayTruncate(n int) int {
method mayError (line 692) | func (p *FaultyBuffer) mayError() error {
method randN (line 699) | func (p *FaultyBuffer) randN(n int) int {
FILE: pkg/internal/third_party/go-json-experiment/json/decode.go
type DecodeOptions (line 50) | type DecodeOptions struct
method NewDecoder (line 141) | func (o DecodeOptions) NewDecoder(r io.Reader) *Decoder {
method ResetDecoder (line 149) | func (o DecodeOptions) ResetDecoder(d *Decoder, r io.Reader) {
type Decoder (line 97) | type Decoder struct
method reset (line 159) | func (d *Decoder) reset(b []byte, r io.Reader, o DecodeOptions) {
method Reset (line 167) | func (d *Decoder) Reset(r io.Reader) {
method fetch (line 175) | func (d *Decoder) fetch() error {
method PeekKind (line 297) | func (d *Decoder) PeekKind() Kind {
method SkipValue (line 352) | func (d *Decoder) SkipValue() error {
method ReadToken (line 379) | func (d *Decoder) ReadToken() (Token, error) {
method ReadValue (line 593) | func (d *Decoder) ReadValue() (RawValue, error) {
method readValue (line 597) | func (d *Decoder) readValue(flags *valueFlags) (RawValue, error) {
method checkEOF (line 697) | func (d *Decoder) checkEOF() error {
method consumeWhitespace (line 725) | func (d *Decoder) consumeWhitespace(pos int) (newPos int, err error) {
method consumeValue (line 743) | func (d *Decoder) consumeValue(flags *valueFlags, pos int) (newPos int...
method consumeLiteral (line 792) | func (d *Decoder) consumeLiteral(pos int, lit string) (newPos int, err...
method consumeString (line 810) | func (d *Decoder) consumeString(flags *valueFlags, pos int) (newPos in...
method consumeNumber (line 829) | func (d *Decoder) consumeNumber(pos int) (newPos int, err error) {
method consumeObject (line 855) | func (d *Decoder) consumeObject(flags *valueFlags, pos int) (newPos in...
method consumeArray (line 953) | func (d *Decoder) consumeArray(flags *valueFlags, pos int) (newPos int...
method InputOffset (line 1009) | func (d *Decoder) InputOffset() int64 {
method UnreadBuffer (line 1017) | func (d *Decoder) UnreadBuffer() []byte {
method StackDepth (line 1026) | func (d *Decoder) StackDepth() int {
method StackIndex (line 1043) | func (d *Decoder) StackIndex(i int) (Kind, int) {
method StackPointer (line 1058) | func (d *Decoder) StackPointer() string {
type decodeBuffer (line 115) | type decodeBuffer struct
method invalidatePreviousRead (line 261) | func (d *decodeBuffer) invalidatePreviousRead() {
method needMore (line 275) | func (d *decodeBuffer) needMore(pos int) bool {
method injectSyntacticErrorWithPosition (line 283) | func (d *decodeBuffer) injectSyntacticErrorWithPosition(err error, pos...
method previousOffsetStart (line 290) | func (d *decodeBuffer) previousOffsetStart() int64 { return d.baseOffs...
method previousOffsetEnd (line 291) | func (d *decodeBuffer) previousOffsetEnd() int64 { return d.baseOffs...
method previousBuffer (line 292) | func (d *decodeBuffer) previousBuffer() []byte { return d.buf[d.pr...
method unreadBuffer (line 293) | func (d *decodeBuffer) unreadBuffer() []byte { return d.buf[d.pr...
function NewDecoder (line 135) | func NewDecoder(r io.Reader) *Decoder {
constant invalidateBufferByte (line 255) | invalidateBufferByte = '#'
type valueFlags (line 572) | type valueFlags
method set (line 582) | func (f *valueFlags) set(f2 valueFlags) { *f |= f2 }
method isVerbatim (line 583) | func (f valueFlags) isVerbatim() bool { return f&stringNonVerbatim =...
method isCanonical (line 584) | func (f valueFlags) isCanonical() bool { return f&stringNonCanonical ...
constant _ (line 575) | _ valueFlags = (1 << iota) / 2
constant stringNonVerbatim (line 577) | stringNonVerbatim
constant stringNonCanonical (line 578) | stringNonCanonical
function consumeWhitespace (line 1064) | func consumeWhitespace(b []byte) (n int) {
function consumeNull (line 1074) | func consumeNull(b []byte) int {
function consumeFalse (line 1085) | func consumeFalse(b []byte) int {
function consumeTrue (line 1096) | func consumeTrue(b []byte) int {
function consumeLiteral (line 1107) | func consumeLiteral(b []byte, lit string) (n int, err error) {
function consumeSimpleString (line 1123) | func consumeSimpleString(b []byte) (n int) {
function consumeString (line 1143) | func consumeString(flags *valueFlags, b []byte, validateUTF8 bool) (n in...
function consumeStringResumable (line 1149) | func consumeStringResumable(flags *valueFlags, b []byte, resumeOffset in...
function hasEscapeSequencePrefix (line 1283) | func hasEscapeSequencePrefix(b []byte) bool {
function unescapeString (line 1300) | func unescapeString(dst, src []byte) (v []byte, ok bool) {
function unescapeStringMayCopy (line 1415) | func unescapeStringMayCopy(b []byte, isVerbatim bool) []byte {
function consumeSimpleNumber (line 1428) | func consumeSimpleNumber(b []byte) (n int) {
type consumeNumberState (line 1448) | type consumeNumberState
constant consumeNumberInit (line 1451) | consumeNumberInit consumeNumberState = iota
constant beforeIntegerDigits (line 1452) | beforeIntegerDigits
constant withinIntegerDigits (line 1453) | withinIntegerDigits
constant beforeFractionalDigits (line 1454) | beforeFractionalDigits
constant withinFractionalDigits (line 1455) | withinFractionalDigits
constant beforeExponentDigits (line 1456) | beforeExponentDigits
constant withinExponentDigits (line 1457) | withinExponentDigits
function consumeNumber (line 1467) | func consumeNumber(b []byte) (n int, err error) {
function consumeNumberResumable (line 1474) | func consumeNumberResumable(b []byte, resumeOffset int, state consumeNum...
function parseHexUint16 (line 1570) | func parseHexUint16(b []byte) (v uint16, ok bool) {
function parseDecUint (line 1595) | func parseDecUint(b []byte) (v uint64, ok bool) {
function parseFloat (line 1627) | func parseFloat(b []byte, bits int) (v float64, ok bool) {
FILE: pkg/internal/third_party/go-json-experiment/json/decode_test.go
function equalTokens (line 22) | func equalTokens(xs, ys []Token) bool {
function TestDecoder (line 35) | func TestDecoder(t *testing.T) {
function testDecoder (line 44) | func testDecoder(t *testing.T, where pc, typeName string, td coderTestda...
function TestFaultyDecoder (line 112) | func TestFaultyDecoder(t *testing.T) {
function testFaultyDecoder (line 121) | func testFaultyDecoder(t *testing.T, where pc, typeName string, td coder...
type decoderMethodCall (line 173) | type decoderMethodCall struct
function TestDecoderErrors (line 653) | func TestDecoderErrors(t *testing.T) {
function testDecoderErrors (line 660) | func testDecoderErrors(t *testing.T, where pc, opts DecodeOptions, in st...
function TestBufferDecoder (line 738) | func TestBufferDecoder(t *testing.T) {
function TestResumableDecoder (line 756) | func TestResumableDecoder(t *testing.T) {
function TestBlockingDecoder (line 775) | func TestBlockingDecoder(t *testing.T) {
function TestPeekableDecoder (line 838) | func TestPeekableDecoder(t *testing.T) {
function TestConsumeWhitespace (line 930) | func TestConsumeWhitespace(t *testing.T) {
function TestConsumeLiteral (line 953) | func TestConsumeLiteral(t *testing.T) {
function TestConsumeString (line 1017) | func TestConsumeString(t *testing.T) {
function TestConsumeNumber (line 1126) | func TestConsumeNumber(t *testing.T) {
function TestParseHexUint16 (line 1219) | func TestParseHexUint16(t *testing.T) {
function TestParseDecUint (line 1247) | func TestParseDecUint(t *testing.T) {
function TestParseFloat (line 1282) | func TestParseFloat(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/diff_test.go
function TestCaseSensitivity (line 48) | func TestCaseSensitivity(t *testing.T) {
function TestOmitEmptyOption (line 138) | func TestOmitEmptyOption(t *testing.T) {
function addr (line 247) | func addr[T any](v T) *T {
function TestStringOption (line 296) | func TestStringOption(t *testing.T) {
function TestNilSlicesAndMaps (line 477) | func TestNilSlicesAndMaps(t *testing.T) {
function TestArrays (line 512) | func TestArrays(t *testing.T) {
function TestByteArrays (line 554) | func TestByteArrays(t *testing.T) {
type CallCheck (line 591) | type CallCheck
method MarshalJSON (line 594) | func (*CallCheck) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 599) | func (v *CallCheck) UnmarshalJSON([]byte) error {
function TestPointerReceiver (line 621) | func TestPointerReceiver(t *testing.T) {
function TestMapDeterminism (line 705) | func TestMapDeterminism(t *testing.T) {
function TestEscapeHTML (line 741) | func TestEscapeHTML(t *testing.T) {
function TestInvalidUTF8 (line 780) | func TestInvalidUTF8(t *testing.T) {
function TestDuplicateNames (line 844) | func TestDuplicateNames(t *testing.T) {
function TestMergeNull (line 875) | func TestMergeNull(t *testing.T) {
function TestMergeComposite (line 955) | func TestMergeComposite(t *testing.T) {
function TestTimeDurations (line 1042) | func TestTimeDurations(t *testing.T) {
function TestMaxFloats (line 1083) | func TestMaxFloats(t *testing.T) {
function TestEmptyStructs (line 1110) | func TestEmptyStructs(t *testing.T) {
function TestEmbedUnexported (line 1185) | func TestEmbedUnexported(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/doc.go
type requireKeyedLiterals (line 179) | type requireKeyedLiterals struct
type nonComparable (line 182) | type nonComparable
FILE: pkg/internal/third_party/go-json-experiment/json/encode.go
type EncodeOptions (line 20) | type EncodeOptions struct
method NewEncoder (line 144) | func (o EncodeOptions) NewEncoder(w io.Writer) *Encoder {
method ResetEncoder (line 152) | func (o EncodeOptions) ResetEncoder(e *Encoder, w io.Writer) {
type Encoder (line 102) | type Encoder struct
method reset (line 162) | func (e *Encoder) reset(b []byte, w io.Writer, o EncodeOptions) {
method Reset (line 182) | func (e *Encoder) Reset(w io.Writer) {
method needFlush (line 187) | func (e *Encoder) needFlush() bool {
method flush (line 199) | func (e *Encoder) flush() error {
method avoidFlush (line 271) | func (e *Encoder) avoidFlush() bool {
method unwriteEmptyObjectMember (line 293) | func (e *Encoder) unwriteEmptyObjectMember(prevName *string) bool {
method unwriteOnlyObjectMemberName (line 352) | func (e *Encoder) unwriteOnlyObjectMemberName() string {
method WriteToken (line 418) | func (e *Encoder) WriteToken(t Token) error {
method writeNumber (line 510) | func (e *Encoder) writeNumber(v float64, bits int, quote bool) error {
method WriteValue (line 583) | func (e *Encoder) WriteValue(v RawValue) error {
method appendWhitespace (line 655) | func (e *Encoder) appendWhitespace(b []byte, next Kind) []byte {
method appendIndent (line 665) | func (e *Encoder) appendIndent(b []byte, n int) []byte {
method reformatValue (line 680) | func (e *Encoder) reformatValue(dst []byte, src RawValue, depth int) (...
method reformatObject (line 729) | func (e *Encoder) reformatObject(dst []byte, src RawValue, depth int) ...
method reformatArray (line 826) | func (e *Encoder) reformatArray(dst []byte, src RawValue, depth int) (...
method OutputOffset (line 886) | func (e *Encoder) OutputOffset() int64 {
method UnusedBuffer (line 903) | func (e *Encoder) UnusedBuffer() []byte {
method StackDepth (line 922) | func (e *Encoder) StackDepth() int {
method StackIndex (line 939) | func (e *Encoder) StackIndex(i int) (Kind, int) {
method StackPointer (line 954) | func (e *Encoder) StackPointer() string {
type encodeBuffer (line 114) | type encodeBuffer struct
method previousOffsetEnd (line 266) | func (e *encodeBuffer) previousOffsetEnd() int64 { return e.baseOffset...
method unflushedBuffer (line 267) | func (e *encodeBuffer) unflushedBuffer() []byte { return e.buf }
function NewEncoder (line 133) | func NewEncoder(w io.Writer) *Encoder {
function trimSuffixWhitespace (line 374) | func trimSuffixWhitespace(b []byte) []byte {
function trimSuffixString (line 383) | func trimSuffixString(b []byte) []byte {
function hasSuffixByte (line 397) | func hasSuffixByte(b []byte, c byte) bool {
function trimSuffixByte (line 402) | func trimSuffixByte(b []byte, c byte) []byte {
constant rawIntNumber (line 502) | rawIntNumber = -1
constant rawUintNumber (line 503) | rawUintNumber = -2
function appendString (line 970) | func appendString(dst []byte, src string, validateUTF8 bool, escapeRune ...
function reformatString (line 1076) | func reformatString(dst, src []byte, validateUTF8, preserveRaw bool, esc...
function appendNumber (line 1108) | func appendNumber(dst []byte, src float64, bits int) []byte {
function reformatNumber (line 1136) | func reformatNumber(dst, src []byte, canonicalize bool) ([]byte, []byte,...
function appendHexUint16 (line 1166) | func appendHexUint16(dst []byte, src uint16) []byte {
FILE: pkg/internal/third_party/go-json-experiment/json/encode_test.go
function TestEncoder (line 29) | func TestEncoder(t *testing.T) {
function testEncoder (line 40) | func testEncoder(t *testing.T, where pc, formatName, typeName string, td...
function TestFaultyEncoder (line 106) | func TestFaultyEncoder(t *testing.T) {
function testFaultyEncoder (line 115) | func testFaultyEncoder(t *testing.T, where pc, typeName string, td coder...
type encoderMethodCall (line 148) | type encoderMethodCall struct
function TestEncoderErrors (line 413) | func TestEncoderErrors(t *testing.T) {
function testEncoderErrors (line 420) | func testEncoderErrors(t *testing.T, where pc, opts EncodeOptions, calls...
function TestAppendString (line 452) | func TestAppendString(t *testing.T) {
function TestAppendNumber (line 517) | func TestAppendNumber(t *testing.T) {
function TestCanonicalNumber (line 602) | func TestCanonicalNumber(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/errors.go
constant errorPrefix (line 15) | errorPrefix = "json: "
constant Error (line 18) | Error = jsonError("json error")
type jsonError (line 20) | type jsonError
method Error (line 22) | func (e jsonError) Error() string {
method Is (line 25) | func (e jsonError) Is(target error) bool {
type ioError (line 29) | type ioError struct
method Error (line 34) | func (e *ioError) Error() string {
method Unwrap (line 37) | func (e *ioError) Unwrap() error {
method Is (line 40) | func (e *ioError) Is(target error) bool {
type SemanticError (line 48) | type SemanticError struct
method Error (line 69) | func (e *SemanticError) Error() string {
method Is (line 142) | func (e *SemanticError) Is(target error) bool {
method Unwrap (line 145) | func (e *SemanticError) Unwrap() error {
type SyntacticError (line 153) | type SyntacticError struct
method Error (line 162) | func (e *SyntacticError) Error() string {
method Is (line 165) | func (e *SyntacticError) Is(target error) bool {
method withOffset (line 168) | func (e *SyntacticError) withOffset(pos int64) error {
function newInvalidCharacterError (line 172) | func newInvalidCharacterError(prefix []byte, where string) *SyntacticErr...
function quoteRune (line 177) | func quoteRune(b []byte) string {
FILE: pkg/internal/third_party/go-json-experiment/json/errors_test.go
function TestSemanticError (line 19) | func TestSemanticError(t *testing.T) {
function TestErrorsIs (line 88) | func TestErrorsIs(t *testing.T) {
function TestQuoteRune (line 172) | func TestQuoteRune(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/example_orderedobject_test.go
type OrderedObject (line 22) | type OrderedObject
type ObjectMember (line 25) | type ObjectMember struct
method MarshalNextJSON (line 31) | func (obj *OrderedObject[V]) MarshalNextJSON(opts json.MarshalOptions, e...
method UnmarshalNextJSON (line 51) | func (obj *OrderedObject[V]) UnmarshalNextJSON(opts json.UnmarshalOption...
function Example_orderedObject (line 76) | func Example_orderedObject() {
FILE: pkg/internal/third_party/go-json-experiment/json/example_test.go
function Example_textMarshal (line 29) | func Example_textMarshal() {
function Example_fieldNames (line 70) | func Example_fieldNames() {
function Example_caseSensitivity (line 115) | func Example_caseSensitivity() {
function Example_omitFields (line 161) | func Example_omitFields() {
function Example_inlinedFields (line 289) | func Example_inlinedFields() {
function Example_unknownMembers (line 345) | func Example_unknownMembers() {
function Example_formatFlags (line 406) | func Example_formatFlags() {
function Example_serveHTTP (line 461) | func Example_serveHTTP() {
function Example_protoJSON (line 496) | func Example_protoJSON() {
function Example_stringReplace (line 544) | func Example_stringReplace() {
function ExampleEncodeOptions_escapeHTML (line 627) | func ExampleEncodeOptions_escapeHTML() {
function ExampleMarshalOptions_errors (line 666) | func ExampleMarshalOptions_errors() {
function ExampleUnmarshalOptions_rawNumber (line 719) | func ExampleUnmarshalOptions_rawNumber() {
function ExampleUnmarshalOptions_recordOffsets (line 754) | func ExampleUnmarshalOptions_recordOffsets() {
FILE: pkg/internal/third_party/go-json-experiment/json/fields.go
type isZeroer (line 21) | type isZeroer interface
type structFields (line 27) | type structFields struct
type structField (line 34) | type structField struct
function makeStructFields (line 44) | func makeStructFields(root reflect.Type) (structFields, *SemanticError) {
type fieldOptions (line 313) | type fieldOptions struct
function parseFieldOptions (line 330) | func parseFieldOptions(sf reflect.StructField) (out fieldOptions, err er...
function consumeTagOption (line 454) | func consumeTagOption(in string) (string, int, error) {
function isLetterOrDigit (line 507) | func isLetterOrDigit(r rune) bool {
FILE: pkg/internal/third_party/go-json-experiment/json/fields_test.go
type unexported (line 14) | type unexported struct
function TestMakeStructFields (line 16) | func TestMakeStructFields(t *testing.T) {
function TestParseTagOptions (line 335) | func TestParseTagOptions(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/fold.go
function foldName (line 15) | func foldName(in []byte) []byte {
function appendFoldedName (line 21) | func appendFoldedName(out, in []byte) []byte {
function foldRune (line 48) | func foldRune(r rune) rune {
FILE: pkg/internal/third_party/go-json-experiment/json/fold_test.go
function TestEqualFold (line 60) | func TestEqualFold(t *testing.T) {
function equalFold (line 69) | func equalFold(x, y []byte) bool {
function TestFoldRune (line 73) | func TestFoldRune(t *testing.T) {
function TestBenchmarkUnmarshalUnknown (line 106) | func TestBenchmarkUnmarshalUnknown(t *testing.T) { runUnmarshalUnknown(t) }
function BenchmarkUnmarshalUnknown (line 107) | func BenchmarkUnmarshalUnknown(b *testing.B) { runUnmarshalUnknown(b) }
function runUnmarshalUnknown (line 109) | func runUnmarshalUnknown(tb testing.TB) {
FILE: pkg/internal/third_party/go-json-experiment/json/fuzz_test.go
function FuzzCoder (line 16) | func FuzzCoder(f *testing.F) {
function FuzzResumableDecoder (line 104) | func FuzzResumableDecoder(f *testing.F) {
function FuzzRawValueReformat (line 135) | func FuzzRawValueReformat(f *testing.F) {
function FuzzEqualFold (line 224) | func FuzzEqualFold(f *testing.F) {
FILE: pkg/internal/third_party/go-json-experiment/json/inline_test.go
function TestInline (line 21) | func TestInline(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/intern.go
type stringCache (line 13) | type stringCache
method make (line 18) | func (c *stringCache) make(b []byte) string {
function hash64 (line 56) | func hash64(lo, hi uint32) uint32 {
FILE: pkg/internal/third_party/go-json-experiment/json/intern_test.go
function TestIntern (line 14) | func TestIntern(t *testing.T) {
function BenchmarkIntern (line 33) | func BenchmarkIntern(b *testing.B) {
FILE: pkg/internal/third_party/go-json-experiment/json/pools.go
type bufferStatistics (line 38) | type bufferStatistics struct
function getBufferedEncoder (line 43) | func getBufferedEncoder(o EncodeOptions) *Encoder {
function putBufferedEncoder (line 55) | func putBufferedEncoder(e *Encoder) {
function getStreamingEncoder (line 85) | func getStreamingEncoder(w io.Writer, o EncodeOptions) *Encoder {
function putStreamingEncoder (line 96) | func putStreamingEncoder(e *Encoder) {
function getBufferedDecoder (line 122) | func getBufferedDecoder(b []byte, o DecodeOptions) *Decoder {
function putBufferedDecoder (line 127) | func putBufferedDecoder(d *Decoder) {
function getStreamingDecoder (line 131) | func getStreamingDecoder(r io.Reader, o DecodeOptions) *Decoder {
function putStreamingDecoder (line 142) | func putStreamingDecoder(d *Decoder) {
type stringSlice (line 155) | type stringSlice
method Sort (line 175) | func (ss *stringSlice) Sort() {
method Len (line 180) | func (ss *stringSlice) Len() int { return len(*ss) }
method Less (line 181) | func (ss *stringSlice) Less(i, j int) bool { return lessUTF16((*ss)[i]...
method Swap (line 182) | func (ss *stringSlice) Swap(i, j int) { (*ss)[i], (*ss)[j] = (*ss...
function getStrings (line 158) | func getStrings(n int) *stringSlice {
function putStrings (line 167) | func putStrings(s *stringSlice) {
FILE: pkg/internal/third_party/go-json-experiment/json/state.go
constant errInvalidNamespace (line 20) | errInvalidNamespace = jsonError("object namespace is in an invalid state")
type state (line 22) | type state struct
method reset (line 38) | func (s *state) reset() {
method appendStackPointer (line 49) | func (s state) appendStackPointer(b []byte) []byte {
type stateMachine (line 97) | type stateMachine struct
method reset (line 104) | func (m *stateMachine) reset() {
method depth (line 114) | func (m stateMachine) depth() int {
method index (line 120) | func (m *stateMachine) index(i int) *stateEntry {
method depthLength (line 129) | func (m stateMachine) depthLength() (int, int) {
method appendLiteral (line 135) | func (m *stateMachine) appendLiteral() error {
method appendString (line 149) | func (m *stateMachine) appendString() error {
method appendNumber (line 161) | func (m *stateMachine) appendNumber() error {
method pushObject (line 167) | func (m *stateMachine) pushObject() error {
method popObject (line 183) | func (m *stateMachine) popObject() error {
method pushArray (line 200) | func (m *stateMachine) pushArray() error {
method popArray (line 216) | func (m *stateMachine) popArray() error {
method needIndent (line 233) | func (m stateMachine) needIndent(next Kind) (n int) {
method mayAppendDelim (line 250) | func (m stateMachine) mayAppendDelim(b []byte, next Kind) []byte {
method needDelim (line 264) | func (m stateMachine) needDelim(next Kind) (delim byte) {
method checkDelim (line 277) | func (m stateMachine) checkDelim(delim byte, next Kind) error {
method invalidateDisabledNamespaces (line 297) | func (m *stateMachine) invalidateDisabledNamespaces() {
type stateEntry (line 310) | type stateEntry
method length (line 334) | func (e stateEntry) length() int {
method isObject (line 339) | func (e stateEntry) isObject() bool {
method isArray (line 344) | func (e stateEntry) isArray() bool {
method needObjectName (line 350) | func (e stateEntry) needObjectName() bool {
method needImplicitColon (line 356) | func (e stateEntry) needImplicitColon() bool {
method needObjectValue (line 362) | func (e stateEntry) needObjectValue() bool {
method needImplicitComma (line 369) | func (e stateEntry) needImplicitComma(next Kind) bool {
method increment (line 376) | func (e *stateEntry) increment() {
method decrement (line 382) | func (e *stateEntry) decrement() {
method disableNamespace (line 388) | func (e *stateEntry) disableNamespace() {
method isActiveNamespace (line 394) | func (e stateEntry) isActiveNamespace() bool {
method invalidateNamespace (line 399) | func (e *stateEntry) invalidateNamespace() {
method isValidNamespace (line 404) | func (e stateEntry) isValidNamespace() bool {
constant stateTypeMask (line 314) | stateTypeMask stateEntry = 0x8000_0000_0000_0000
constant stateTypeObject (line 315) | stateTypeObject stateEntry = 0x8000_0000_0000_0000
constant stateTypeArray (line 316) | stateTypeArray stateEntry = 0x0000_0000_0000_0000
constant stateNamespaceMask (line 321) | stateNamespaceMask stateEntry = 0x6000_0000_0000_0000
constant stateDisableNamespace (line 322) | stateDisableNamespace stateEntry = 0x4000_0000_0000_0000
constant stateInvalidNamespace (line 323) | stateInvalidNamespace stateEntry = 0x2000_0000_0000_0000
constant stateCountMask (line 326) | stateCountMask stateEntry = 0x1fff_ffff_ffff_ffff
constant stateCountLSBMask (line 327) | stateCountLSBMask stateEntry = 0x0000_0000_0000_0001
constant stateCountOdd (line 328) | stateCountOdd stateEntry = 0x0000_0000_0000_0001
constant stateCountEven (line 329) | stateCountEven stateEntry = 0x0000_0000_0000_0000
type objectNameStack (line 418) | type objectNameStack struct
method reset (line 430) | func (ns *objectNameStack) reset() {
method length (line 441) | func (ns *objectNameStack) length() int {
method getUnquoted (line 449) | func (ns *objectNameStack) getUnquoted(i int) []byte {
method push (line 462) | func (ns *objectNameStack) push() {
method replaceLastQuotedOffset (line 469) | func (ns *objectNameStack) replaceLastQuotedOffset(i int) {
method replaceLastUnquotedName (line 481) | func (ns *objectNameStack) replaceLastUnquotedName(s string) {
method clearLast (line 493) | func (ns *objectNameStack) clearLast() {
method pop (line 498) | func (ns *objectNameStack) pop() {
method copyQuotedBuffer (line 506) | func (ns *objectNameStack) copyQuotedBuffer(b []byte) {
method ensureCopiedBuffer (line 546) | func (ns *objectNameStack) ensureCopiedBuffer() {
constant invalidOffset (line 459) | invalidOffset = math.MinInt
type objectNamespaceStack (line 554) | type objectNamespaceStack
method reset (line 557) | func (nss *objectNamespaceStack) reset() {
method push (line 565) | func (nss *objectNamespaceStack) push() {
method last (line 575) | func (nss objectNamespaceStack) last() *objectNamespace {
method pop (line 580) | func (nss *objectNamespaceStack) pop() {
type objectNamespace (line 589) | type objectNamespace struct
method reset (line 604) | func (ns *objectNamespace) reset() {
method length (line 617) | func (ns *objectNamespace) length() int {
method getUnquoted (line 622) | func (ns *objectNamespace) getUnquoted(i int) []byte {
method lastUnquoted (line 631) | func (ns *objectNamespace) lastUnquoted() []byte {
method insertQuoted (line 638) | func (ns *objectNamespace) insertQuoted(name []byte, isVerbatim bool) ...
method insertUnquoted (line 644) | func (ns *objectNamespace) insertUnquoted(name []byte) bool {
method insert (line 647) | func (ns *objectNamespace) insert(name []byte, quoted bool) bool {
method removeLast (line 693) | func (ns *objectNamespace) removeLast() {
type uintSet64 (line 706) | type uintSet64
method has (line 708) | func (s uintSet64) has(i uint) bool { return s&(1<<i) > 0 }
method set (line 709) | func (s *uintSet64) set(i uint) { *s |= 1 << i }
type uintSet (line 713) | type uintSet struct
method has (line 719) | func (s *uintSet) has(i uint) bool {
method insert (line 730) | func (s *uintSet) insert(i uint) bool {
FILE: pkg/internal/third_party/go-json-experiment/json/state_test.go
function TestStateMachine (line 14) | func TestStateMachine(t *testing.T) {
method append (line 190) | func (s *stateMachine) append(k Kind) error {
function TestObjectNamespace (line 211) | func TestObjectNamespace(t *testing.T) {
function TestUintSet (line 339) | func TestUintSet(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/testdata_test.go
type jsonTestdataEntry (line 20) | type jsonTestdataEntry struct
function jsonTestdata (line 31) | func jsonTestdata() []jsonTestdataEntry {
type canadaRoot (line 98) | type canadaRoot struct
type citmRoot (line 114) | type citmRoot struct
type golangRoot (line 159) | type golangRoot struct
type golangNode (line 163) | type golangNode struct
type stringRoot (line 175) | type stringRoot struct
type syntheaRoot (line 240) | type syntheaRoot struct
type syntheaCode (line 428) | type syntheaCode struct
type syntheaCoding (line 432) | type syntheaCoding struct
type syntheaReference (line 439) | type syntheaReference struct
type syntheaAddress (line 443) | type syntheaAddress struct
type syntheaExtension (line 451) | type syntheaExtension struct
type syntheaRange (line 459) | type syntheaRange struct
type syntheaCurrency (line 463) | type syntheaCurrency struct
type twitterRoot (line 470) | type twitterRoot struct
type twitterStatus (line 484) | type twitterStatus struct
type twitterUser (line 514) | type twitterUser struct
type twitterEntities (line 556) | type twitterEntities struct
type twitterURL (line 590) | type twitterURL struct
FILE: pkg/internal/third_party/go-json-experiment/json/token.go
constant maxInt64 (line 15) | maxInt64 = math.MaxInt64
constant minInt64 (line 16) | minInt64 = math.MinInt64
constant maxUint64 (line 17) | maxUint64 = math.MaxUint64
constant minUint64 (line 18) | minUint64 = 0
constant invalidTokenPanic (line 20) | invalidTokenPanic = "invalid json.Token; it has been voided by a subsequ...
type Token (line 33) | type Token struct
method Clone (line 160) | func (t Token) Clone() Token {
method Bool (line 195) | func (t Token) Bool() bool {
method appendString (line 208) | func (t Token) appendString(dst []byte, validateUTF8, preserveRaw bool...
method String (line 229) | func (t Token) String() string {
method string (line 240) | func (t Token) string() (string, []byte) {
method appendNumber (line 273) | func (t Token) appendNumber(dst []byte, canonicalize bool) ([]byte, er...
method Float (line 303) | func (t Token) Float() float64 {
method Int (line 346) | func (t Token) Int() int64 {
method Uint (line 403) | func (t Token) Uint() uint64 {
method Kind (line 453) | func (t Token) Kind() Kind {
function rawToken (line 103) | func rawToken(s string) Token {
function Bool (line 108) | func Bool(b bool) Token {
function String (line 118) | func String(s string) Token {
function Float (line 128) | func Float(n float64) Token {
function Int (line 143) | func Int(n int64) Token {
function Uint (line 151) | func Uint(n uint64) Token {
type Kind (line 486) | type Kind
method String (line 491) | func (k Kind) String() string {
method normalize (line 517) | func (k Kind) normalize() Kind {
constant invalidKind (line 488) | invalidKind Kind = 0
FILE: pkg/internal/third_party/go-json-experiment/json/token_test.go
function TestTokenStringAllocations (line 13) | func TestTokenStringAllocations(t *testing.T) {
function TestTokenAccessors (line 32) | func TestTokenAccessors(t *testing.T) {
function TestTokenClone (line 135) | func TestTokenClone(t *testing.T) {
FILE: pkg/internal/third_party/go-json-experiment/json/value.go
type RawValue (line 28) | type RawValue
method Clone (line 31) | func (v RawValue) Clone() RawValue {
method String (line 39) | func (v RawValue) String() string {
method IsValid (line 54) | func (v RawValue) IsValid() bool {
method Compact (line 67) | func (v *RawValue) Compact() error {
method Indent (line 80) | func (v *RawValue) Indent(prefix, indent string) error {
method Canonicalize (line 102) | func (v *RawValue) Canonicalize() error {
method MarshalJSON (line 112) | func (v RawValue) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 122) | func (v *RawValue) UnmarshalJSON(b []byte) error {
method Kind (line 133) | func (v RawValue) Kind() Kind {
method reformat (line 140) | func (v *RawValue) reformat(canonical, multiline bool, prefix, indent ...
function trimLeftSpaceTab (line 191) | func trimLeftSpaceTab(s string) string {
type memberName (line 202) | type memberName struct
function getMemberNames (line 212) | func getMemberNames() *memberNames {
function putMemberNames (line 217) | func putMemberNames(ns *memberNames) {
type memberNames (line 226) | type memberNames
method Len (line 228) | func (m *memberNames) Len() int { return len(*m) }
method Less (line 229) | func (m *memberNames) Less(i, j int) bool { return lessUTF16((*m)[i].n...
method Swap (line 230) | func (m *memberNames) Swap(i, j int) { (*m)[i], (*m)[j] = (*m)[j]...
function reorderObjects (line 247) | func reorderObjects(d *Decoder, scratch *[]byte) {
function lessUTF16 (line 320) | func lessUTF16[Bytes []byte | string](x, y Bytes) bool {
FILE: pkg/internal/third_party/go-json-experiment/json/value_test.go
type rawValueTestdataEntry (line 14) | type rawValueTestdataEntry struct
function TestRawValueMethods (line 134) | func TestRawValueMethods(t *testing.T) {
function TestLessUTF16 (line 191) | func TestLessUTF16(t *testing.T) {
function FuzzLessUTF16 (line 203) | func FuzzLessUTF16(f *testing.F) {
FILE: pkg/internal/third_party/govalidator/patterns.go
constant CreditCard (line 7) | CreditCard string = "^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011...
constant ISBN10 (line 8) | ISBN10 string = "^(?:[0-9]{9}X|[0-9]{10})$"
constant ISBN13 (line 9) | ISBN13 string = "^(?:[0-9]{13})$"
constant Hexcolor (line 10) | Hexcolor string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
constant RGBcolor (line 11) | RGBcolor string = "^rgb\\(\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])...
constant Base64 (line 12) | Base64 string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-...
constant SSN (line 13) | SSN string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$`
constant Int (line 14) | Int string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
FILE: pkg/internal/third_party/govalidator/validator.go
function IsRequestURI (line 22) | func IsRequestURI(rawurl string) bool {
function IsHexcolor (line 28) | func IsHexcolor(str string) bool {
function IsRGBcolor (line 33) | func IsRGBcolor(str string) bool {
function IsCreditCard (line 38) | func IsCreditCard(str string) bool {
function IsISBN10 (line 67) | func IsISBN10(str string) bool {
function IsISBN13 (line 72) | func IsISBN13(str string) bool {
function IsISBN (line 78) | func IsISBN(str string, version int) bool {
function IsBase64 (line 112) | func IsBase64(str string) bool {
function IsIPv6 (line 117) | func IsIPv6(str string) bool {
function IsMAC (line 130) | func IsMAC(str string) bool {
function IsSSN (line 136) | func IsSSN(str string) bool {
function ToInt (line 144) | func ToInt(value interface{}) (res int64, err error) {
function IsInt (line 171) | func IsInt(str string) bool {
function IsNull (line 179) | func IsNull(str string) bool {
FILE: pkg/internal/third_party/govalidator/validator_test.go
function TestIsRequestURI (line 7) | func TestIsRequestURI(t *testing.T) {
function TestIsHexcolor (line 55) | func TestIsHexcolor(t *testing.T) {
function TestIsRGBcolor (line 78) | func TestIsRGBcolor(t *testing.T) {
function TestIsCreditCard (line 101) | func TestIsCreditCard(t *testing.T) {
function TestIsISBN (line 136) | func TestIsISBN(t *testing.T) {
function TestIsBase64 (line 208) | func TestIsBase64(t *testing.T) {
function TestIIsIPv6 (line 236) | func TestIIsIPv6(t *testing.T) {
function TestIsMAC (line 261) | func TestIsMAC(t *testing.T) {
function TestIsSSN (line 282) | func TestIsSSN(t *testing.T) {
function TestIsInt (line 303) | func TestIsInt(t *testing.T) {
function TestIsNull (line 340) | func TestIsNull(t *testing.T) {
FILE: pkg/openapiconv/convert.go
function ConvertV2ToV3 (line 33) | func ConvertV2ToV3(v2Spec *spec.Swagger) *spec3.OpenAPI {
function ConvertExternalDocumentation (line 45) | func ConvertExternalDocumentation(v2ED *spec.ExternalDocumentation) *spe...
function ConvertComponents (line 57) | func ConvertComponents(v2SecurityDefinitions spec.SecurityDefinitions, v...
function ConvertSchema (line 82) | func ConvertSchema(v2Schema *spec.Schema) *spec.Schema {
function ConvertSchemaList (line 130) | func ConvertSchemaList(v2SchemaList []spec.Schema) []spec.Schema {
function ConvertSecurityScheme (line 141) | func ConvertSecurityScheme(v2securityScheme *spec.SecurityScheme) *spec3...
function ConvertPaths (line 168) | func ConvertPaths(v2Paths *spec.Paths) *spec3.Paths {
function ConvertPathItem (line 185) | func ConvertPathItem(v2pathItem spec.PathItem) *spec3.Path {
function ConvertOperation (line 205) | func ConvertOperation(v2Operation *spec.Operation) *spec3.Operation {
function ConvertResponse (line 256) | func ConvertResponse(v2Response *spec.Response, produces []string) *spec...
function ConvertParameter (line 283) | func ConvertParameter(v2Param spec.Parameter) *spec3.Parameter {
function ConvertRefableParameter (line 310) | func ConvertRefableParameter(refable spec.Refable) spec.Refable {
function ConvertRefableResponse (line 317) | func ConvertRefableResponse(refable spec.Refable) spec.Refable {
FILE: pkg/openapiconv/convert_test.go
function TestConvert (line 31) | func TestConvert(t *testing.T) {
FILE: pkg/schemaconv/openapi.go
function ToSchemaFromOpenAPI (line 38) | func ToSchemaFromOpenAPI(models map[string]*spec.Schema, preserveUnknown...
method visitSpec (line 77) | func (c *convert) visitSpec(m *spec.Schema) {
method parseSchema (line 86) | func (c *convert) parseSchema(m *spec.Schema) schema.Atom {
method makeOpenAPIRef (line 127) | func (c *convert) makeOpenAPIRef(specSchema *spec.Schema) schema.TypeRef {
method parseObject (line 171) | func (c *convert) parseObject(s *spec.Schema) *schema.Map {
method parseList (line 225) | func (c *convert) parseList(s *spec.Schema) *schema.List {
FILE: pkg/schemaconv/openapi_test.go
constant quantityResource (line 44) | quantityResource = "io.k8s.apimachinery.pkg.api.resource.Quantity"
constant rawExtensionResource (line 45) | rawExtensionResource = "io.k8s.apimachinery.pkg.runtime.RawExtension"
function toPtrMap (line 48) | func toPtrMap[T comparable, V any](m map[T]V) map[T]*V {
function normalizeTypeRef (line 61) | func normalizeTypeRef(tr *schema.TypeRef) {
function normalizeType (line 105) | func normalizeType(typ *schema.Atom) {
function normalizeTypes (line 157) | func normalizeTypes(types []schema.TypeDef) map[string]schema.TypeDef {
function TestCRDOpenAPIConversion (line 224) | func TestCRDOpenAPIConversion(t *testing.T) {
function TestOpenAPIImplementation (line 257) | func TestOpenAPIImplementation(t *testing.T) {
function specToSchemaViaProtoModels (line 274) | func specToSchemaViaProtoModels(input []byte) (*schema.Schema, error) {
function BenchmarkOpenAPIConversion (line 293) | func BenchmarkOpenAPIConversion(b *testing.B) {
function BenchmarkOpenAPICRDConversion (line 322) | func BenchmarkOpenAPICRDConversion(b *testing.B) {
FILE: pkg/schemaconv/proto_models.go
function ToSchema (line 30) | func ToSchema(models proto.Models) (*schema.Schema, error) {
function ToSchemaWithPreserveUnknownFields (line 36) | func ToSchemaWithPreserveUnknownFields(models proto.Models, preserveUnkn...
method makeRef (line 60) | func (c *convert) makeRef(model proto.Schema, preserveUnknownFields bool...
method VisitKind (line 97) | func (c *convert) VisitKind(k *proto.Kind) {
method VisitArray (line 136) | func (c *convert) VisitArray(a *proto.Array) {
method VisitMap (line 150) | func (c *convert) VisitMap(m *proto.Map) {
method VisitPrimitive (line 163) | func (c *convert) VisitPrimitive(p *proto.Primitive) {
method VisitArbitrary (line 172) | func (c *convert) VisitArbitrary(a *proto.Arbitrary) {
method VisitReference (line 176) | func (c *convert) VisitReference(proto.Reference) {
FILE: pkg/schemaconv/smd.go
constant quantityResource (line 27) | quantityResource = "io.k8s.apimachinery.pkg.api.resource.Quantity"
constant rawExtensionResource (line 28) | rawExtensionResource = "io.k8s.apimachinery.pkg.runtime.RawExtension"
type convert (line 31) | type convert struct
method push (line 40) | func (c *convert) push(name string, a *schema.Atom) *convert {
method top (line 49) | func (c *convert) top() *schema.Atom { return c.current }
method pop (line 51) | func (c *convert) pop(c2 *convert) {
method reportError (line 55) | func (c *convert) reportError(format string, args ...interface{}) {
method insertTypeDef (line 61) | func (c *convert) insertTypeDef(name string, atom schema.Atom) {
method addCommonTypes (line 73) | func (c *convert) addCommonTypes() {
function makeUnions (line 120) | func makeUnions(extensions map[string]interface{}) ([]schema.Union, erro...
function makeUnion (line 168) | func makeUnion(extensions map[string]interface{}) (schema.Union, error) {
function toStringSlice (line 220) | func toStringSlice(o interface{}) (out []string, ok bool) {
function ptr (line 236) | func ptr(s schema.Scalar) *schema.Scalar { return &s }
function convertPrimitive (line 240) | func convertPrimitive(typ string, format string) (a schema.Atom) {
function getListElementRelationship (line 269) | func getListElementRelationship(ext map[string]any) (schema.ElementRelat...
function getMapElementRelationship (line 319) | func getMapElementRelationship(ext map[string]any) (schema.ElementRelati...
FILE: pkg/schemaconv/smd_test.go
function TestToSchema (line 31) | func TestToSchema(t *testing.T) {
function testToSchema (line 67) | func testToSchema(t *testing.T, openAPIPath, expectedNewSchemaPath strin...
function TestFieldLevelAnnotation (line 103) | func TestFieldLevelAnnotation(t *testing.T) {
FILE: pkg/schemamutation/walker.go
type Walker (line 25) | type Walker struct
method WalkSchema (line 55) | func (w *Walker) WalkSchema(schema *spec.Schema) *spec.Schema {
method walkParameter (line 209) | func (w *Walker) walkParameter(param *spec.Parameter) *spec.Parameter {
method walkParameters (line 241) | func (w *Walker) walkParameters(params []spec.Parameter) ([]spec.Param...
method walkResponse (line 266) | func (w *Walker) walkResponse(resp *spec.Response) *spec.Response {
method walkResponses (line 293) | func (w *Walker) walkResponses(resps *spec.Responses) *spec.Responses {
method walkOperation (line 331) | func (w *Walker) walkOperation(op *spec.Operation) *spec.Operation {
method walkPathItem (line 367) | func (w *Walker) walkPathItem(pathItem *spec.PathItem) *spec.PathItem {
method walkPaths (line 418) | func (w *Walker) walkPaths(paths *spec.Paths) *spec.Paths {
method WalkRoot (line 451) | func (w *Walker) WalkRoot(swagger *spec.Swagger) *spec.Swagger {
type SchemaCallbackFunc (line 38) | type SchemaCallbackFunc
type RefCallbackFunc (line 39) | type RefCallbackFunc
function ReplaceReferences (line 50) | func ReplaceReferences(walkRef func(ref *spec.Ref) *spec.Ref, sp *spec.S...
FILE: pkg/schemamutation/walker_test.go
function fuzzFuncs (line 36) | func fuzzFuncs(f *randfill.Filler, refFunc func(ref *spec.Ref, c randfil...
function TestReplaceReferences (line 164) | func TestReplaceReferences(t *testing.T) {
function TestReplaceSchema (line 297) | func TestReplaceSchema(t *testing.T) {
function cloneSwagger (line 393) | func cloneSwagger(orig *spec.Swagger) (*spec.Swagger, error) {
function stringDiff (line 406) | func stringDiff(a, b string) string {
function objectDiff (line 428) | func objectDiff(a, b interface{}) string {
function max (line 440) | func max(i, j int) int {
FILE: pkg/spec3/benchmark_serialization_test.go
function TestOpenAPIV3RoundTrip (line 24) | func TestOpenAPIV3RoundTrip(t *testing.T) {
function TestOpenAPIV3Deserialize (line 47) | func TestOpenAPIV3Deserialize(t *testing.T) {
function TestOpenAPIV3Serialize (line 75) | func TestOpenAPIV3Serialize(t *testing.T) {
function TestOpenAPIV3SerializeFuzzed (line 105) | func TestOpenAPIV3SerializeFuzzed(t *testing.T) {
function TestOpenAPIV3SerializeStable (line 131) | func TestOpenAPIV3SerializeStable(t *testing.T) {
function BenchmarkOpenAPIV3Deserialize (line 164) | func BenchmarkOpenAPIV3Deserialize(b *testing.B) {
function BenchmarkOpenAPIV3Serialize (line 236) | func BenchmarkOpenAPIV3Serialize(b *testing.B) {
FILE: pkg/spec3/component.go
type Components (line 26) | type Components struct
type SecuritySchemes (line 47) | type SecuritySchemes
FILE: pkg/spec3/component_test.go
function TestSchemasJSONSerialization (line 31) | func TestSchemasJSONSerialization(t *testing.T) {
FILE: pkg/spec3/encoding.go
type Encoding (line 28) | type Encoding struct
method MarshalJSON (line 34) | func (e *Encoding) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 49) | func (e *Encoding) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *js...
method UnmarshalJSON (line 59) | func (e *Encoding) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 72) | func (e *Encoding) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec...
type EncodingProps (line 86) | type EncodingProps struct
type encodingPropsOmitZero (line 99) | type encodingPropsOmitZero struct
FILE: pkg/spec3/encoding_test.go
function TestEncodingRoundtrip (line 30) | func TestEncodingRoundtrip(t *testing.T) {
function TestEncodingJSONSerialization (line 52) | func TestEncodingJSONSerialization(t *testing.T) {
FILE: pkg/spec3/example.go
type Example (line 31) | type Example struct
method MarshalJSON (line 38) | func (e *Example) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 56) | func (e *Example) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jso...
method UnmarshalJSON (line 68) | func (e *Example) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 84) | func (e *Example) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec ...
type ExampleProps (line 101) | type ExampleProps struct
FILE: pkg/spec3/example_test.go
function TestExampleRoundtrip (line 30) | func TestExampleRoundtrip(t *testing.T) {
function TestExampleJSONSerialization (line 53) | func TestExampleJSONSerialization(t *testing.T) {
FILE: pkg/spec3/external_documentation.go
type ExternalDocumentation (line 28) | type ExternalDocumentation struct
method MarshalJSON (line 41) | func (e *ExternalDocumentation) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 56) | func (e *ExternalDocumentation) MarshalNextJSON(opts jsonv2.MarshalOpt...
method UnmarshalJSON (line 66) | func (e *ExternalDocumentation) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 79) | func (e *ExternalDocumentation) UnmarshalNextJSON(opts jsonv2.Unmarsha...
type ExternalDocumentationProps (line 33) | type ExternalDocumentationProps struct
FILE: pkg/spec3/external_documentation_test.go
function TestExternalDocumentationRoundTrip (line 30) | func TestExternalDocumentationRoundTrip(t *testing.T) {
function TestExternalDocumentationJSONSerialization (line 52) | func TestExternalDocumentationJSONSerialization(t *testing.T) {
FILE: pkg/spec3/fuzz.go
constant refChance (line 15) | refChance = 3
constant alphaNumChars (line 17) | alphaNumChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS...
function randAlphanumString (line 19) | func randAlphanumString() string {
FILE: pkg/spec3/header.go
type Header (line 31) | type Header struct
method MarshalJSON (line 38) | func (h *Header) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 57) | func (h *Header) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *json...
method UnmarshalJSON (line 69) | func (h *Header) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 86) | func (h *Header) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *...
type HeaderProps (line 103) | type HeaderProps struct
type headerPropsOmitZero (line 130) | type headerPropsOmitZero struct
FILE: pkg/spec3/header_test.go
function TestHeaderRoundTrip (line 30) | func TestHeaderRoundTrip(t *testing.T) {
function TestHeaderJSONSerialization (line 53) | func TestHeaderJSONSerialization(t *testing.T) {
FILE: pkg/spec3/media_type.go
type MediaType (line 31) | type MediaType struct
method MarshalJSON (line 37) | func (m *MediaType) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 52) | func (e *MediaType) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *j...
method UnmarshalJSON (line 62) | func (m *MediaType) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 75) | func (m *MediaType) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
type MediaTypeProps (line 90) | type MediaTypeProps struct
type mediaTypePropsOmitZero (line 101) | type mediaTypePropsOmitZero struct
FILE: pkg/spec3/media_type_test.go
function TestMediaTypeRoundTrip (line 30) | func TestMediaTypeRoundTrip(t *testing.T) {
function TestMediaTypeJSONSerialization (line 52) | func TestMediaTypeJSONSerialization(t *testing.T) {
FILE: pkg/spec3/operation.go
type Operation (line 31) | type Operation struct
method MarshalJSON (line 37) | func (o *Operation) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 52) | func (o *Operation) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *j...
method UnmarshalJSON (line 63) | func (o *Operation) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 73) | func (o *Operation) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
type OperationProps (line 87) | type OperationProps struct
type operationPropsOmitZero (line 112) | type operationPropsOmitZero struct
FILE: pkg/spec3/operation_test.go
function TestOperationRoundTrip (line 29) | func TestOperationRoundTrip(t *testing.T) {
function TestOperationJSONSerialization (line 51) | func TestOperationJSONSerialization(t *testing.T) {
FILE: pkg/spec3/parameter.go
type Parameter (line 31) | type Parameter struct
method MarshalJSON (line 38) | func (p *Parameter) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 57) | func (p *Parameter) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *j...
method UnmarshalJSON (line 69) | func (p *Parameter) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 87) | func (p *Parameter) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
type ParameterProps (line 104) | type ParameterProps struct
type parameterPropsOmitZero (line 133) | type parameterPropsOmitZero struct
FILE: pkg/spec3/parameter_test.go
function TestParameterRoundTrip (line 30) | func TestParameterRoundTrip(t *testing.T) {
function TestParameterJSONSerialization (line 53) | func TestParameterJSONSerialization(t *testing.T) {
FILE: pkg/spec3/path.go
type Paths (line 31) | type Paths struct
method MarshalJSON (line 37) | func (p *Paths) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 60) | func (p *Paths) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv...
method UnmarshalJSON (line 76) | func (p *Paths) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 109) | func (p *Paths) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *j...
type Path (line 165) | type Path struct
method MarshalJSON (line 172) | func (p *Path) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 191) | func (p *Path) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2...
method UnmarshalJSON (line 203) | func (p *Path) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 219) | func (p *Path) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *js...
type PathProps (line 238) | type PathProps struct
FILE: pkg/spec3/path_test.go
function TestPathRoundTrip (line 32) | func TestPathRoundTrip(t *testing.T) {
function TestPathJSONSerialization (line 55) | func TestPathJSONSerialization(t *testing.T) {
function TestPathsNullUnmarshal (line 143) | func TestPathsNullUnmarshal(t *testing.T) {
FILE: pkg/spec3/request_body.go
type RequestBody (line 31) | type RequestBody struct
method MarshalJSON (line 38) | func (r *RequestBody) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 57) | func (r *RequestBody) MarshalNextJSON(opts jsonv2.MarshalOptions, enc ...
method UnmarshalJSON (line 69) | func (r *RequestBody) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 101) | func (r *RequestBody) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, ...
type RequestBodyProps (line 86) | type RequestBodyProps struct
type requestBodyPropsOmitZero (line 95) | type requestBodyPropsOmitZero struct
FILE: pkg/spec3/request_body_test.go
function TestRequestBodyRoundTrip (line 30) | func TestRequestBodyRoundTrip(t *testing.T) {
function TestRequestBodyJSONSerialization (line 53) | func TestRequestBodyJSONSerialization(t *testing.T) {
FILE: pkg/spec3/response.go
type Responses (line 33) | type Responses struct
method MarshalJSON (line 39) | func (r *Responses) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 54) | func (r Responses) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *js...
method UnmarshalJSON (line 73) | func (r *Responses) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 139) | func (r *Responses) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
type ResponsesProps (line 87) | type ResponsesProps struct
method MarshalJSON (line 95) | func (r ResponsesProps) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 107) | func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
type Response (line 196) | type Response struct
method MarshalJSON (line 203) | func (r *Response) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 222) | func (r Response) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jso...
method UnmarshalJSON (line 234) | func (r *Response) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 250) | func (r *Response) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec...
type ResponseProps (line 267) | type ResponseProps struct
type Link (line 279) | type Link struct
method MarshalJSON (line 286) | func (r *Link) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 305) | func (r *Link) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2...
method UnmarshalJSON (line 317) | func (r *Link) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 334) | func (l *Link) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *js...
type LinkProps (line 351) | type LinkProps struct
FILE: pkg/spec3/response_test.go
function TestResponsesRoundTrip (line 32) | func TestResponsesRoundTrip(t *testing.T) {
function TestResponseRoundTrip (line 57) | func TestResponseRoundTrip(t *testing.T) {
function TestResponseJSONSerialization (line 80) | func TestResponseJSONSerialization(t *testing.T) {
function TestResponsesNullUnmarshal (line 121) | func TestResponsesNullUnmarshal(t *testing.T) {
FILE: pkg/spec3/security_scheme.go
type SecurityScheme (line 29) | type SecurityScheme struct
method MarshalJSON (line 36) | func (s *SecurityScheme) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 55) | func (s *SecurityScheme) MarshalNextJSON(opts jsonv2.MarshalOptions, e...
method UnmarshalJSON (line 68) | func (s *SecurityScheme) UnmarshalJSON(data []byte) error {
type SecuritySchemeProps (line 79) | type SecuritySchemeProps struct
type OAuthFlow (line 99) | type OAuthFlow struct
method MarshalJSON (line 105) | func (o *OAuthFlow) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 118) | func (o *OAuthFlow) UnmarshalJSON(data []byte) error {
type OAuthFlowProps (line 126) | type OAuthFlowProps struct
FILE: pkg/spec3/security_scheme_test.go
function TestSecuritySchemeRoundTrip (line 31) | func TestSecuritySchemeRoundTrip(t *testing.T) {
function TestSecuritySchemaJSONSerialization (line 54) | func TestSecuritySchemaJSONSerialization(t *testing.T) {
FILE: pkg/spec3/server.go
type Server (line 28) | type Server struct
method MarshalJSON (line 43) | func (s *Server) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 58) | func (s *Server) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *json...
method UnmarshalJSON (line 68) | func (s *Server) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 82) | func (s *Server) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *...
type ServerProps (line 33) | type ServerProps struct
type ServerVariable (line 96) | type ServerVariable struct
method MarshalJSON (line 111) | func (s *ServerVariable) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 126) | func (s *ServerVariable) MarshalNextJSON(opts jsonv2.MarshalOptions, e...
method UnmarshalJSON (line 136) | func (s *ServerVariable) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 149) | func (s *ServerVariable) UnmarshalNextJSON(opts jsonv2.UnmarshalOption...
type ServerVariableProps (line 101) | type ServerVariableProps struct
FILE: pkg/spec3/server_test.go
function TestServerRoundTrip (line 31) | func TestServerRoundTrip(t *testing.T) {
function TestServerJSONSerialization (line 53) | func TestServerJSONSerialization(t *testing.T) {
FILE: pkg/spec3/spec.go
type OpenAPI (line 28) | type OpenAPI struct
method UnmarshalJSON (line 45) | func (o *OpenAPI) UnmarshalJSON(data []byte) error {
method MarshalJSON (line 54) | func (o *OpenAPI) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 63) | func (o *OpenAPI) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jso...
FILE: pkg/util/jsontesting/json_roundtrip.go
function JsonCompare (line 32) | func JsonCompare(got, want []byte) error {
type RoundTripTestCase (line 44) | type RoundTripTestCase struct
method RoundTripTest (line 63) | func (t RoundTripTestCase) RoundTripTest(example MarshalerUnmarshaler)...
type MarshalerUnmarshaler (line 58) | type MarshalerUnmarshaler interface
FILE: pkg/util/proto/document.go
function newSchemaError (line 28) | func newSchemaError(path *Path, format string, a ...interface{}) error {
function VendorExtensionToMap (line 37) | func VendorExtensionToMap(e []*openapi_v2.NamedAny) map[string]interface...
type Definitions (line 61) | type Definitions struct
method parseReference (line 94) | func (d *Definitions) parseReference(s *openapi_v2.Schema, path *Path)...
method parseBaseSchema (line 134) | func (d *Definitions) parseBaseSchema(s *openapi_v2.Schema, path *Path...
method parseMap (line 148) | func (d *Definitions) parseMap(s *openapi_v2.Schema, path *Path) (Sche...
method parsePrimitive (line 179) | func (d *Definitions) parsePrimitive(s *openapi_v2.Schema, path *Path)...
method parseArray (line 207) | func (d *Definitions) parseArray(s *openapi_v2.Schema, path *Path) (Sc...
method parseKind (line 233) | func (d *Definitions) parseKind(s *openapi_v2.Schema, path *Path) (Sch...
method parseArbitrary (line 267) | func (d *Definitions) parseArbitrary(s *openapi_v2.Schema, path *Path)...
method ParseSchema (line 279) | func (d *Definitions) ParseSchema(s *openapi_v2.Schema, path *Path) (S...
method LookupModel (line 324) | func (d *Definitions) LookupModel(model string) Schema {
method ListModels (line 328) | func (d *Definitions) ListModels() []string {
function NewOpenAPIData (line 68) | func NewOpenAPIData(doc *openapi_v2.Document) (Models, error) {
function parseDefault (line 123) | func parseDefault(def *openapi_v2.Any) (interface{}, error) {
type Ref (line 339) | type Ref struct
method Reference (line 348) | func (r *Ref) Reference() string {
method SubSchema (line 352) | func (r *Ref) SubSchema() Schema {
method Accept (line 356) | func (r *Ref) Accept(v SchemaVisitor) {
method GetName (line 360) | func (r *Ref) GetName() string {
FILE: pkg/util/proto/document_v3.go
function NewOpenAPIV3Data (line 30) | func NewOpenAPIV3Data(doc *openapi_v3.Document) (Models, error) {
method ParseV3SchemaReference (line 67) | func (d *Definitions) ParseV3SchemaReference(s *openapi_v3.Reference, pa...
method ParseV3SchemaOrReference (line 95) | func (d *Definitions) ParseV3SchemaOrReference(s *openapi_v3.SchemaOrRef...
method ParseSchemaV3 (line 119) | func (d *Definitions) ParseSchemaV3(s *openapi_v3.Schema, path *Path) (S...
method parseV3Kind (line 143) | func (d *Definitions) parseV3Kind(s *openapi_v3.Schema, path *Path) (Sch...
method parseV3Arbitrary (line 177) | func (d *Definitions) parseV3Arbitrary(s *openapi_v3.Schema, path *Path)...
method parseV3Primitive (line 187) | func (d *Definitions) parseV3Primitive(s *openapi_v3.Schema, path *Path)...
method parseV3Array (line 210) | func (d *Definitions) parseV3Array(s *openapi_v3.Schema, path *Path) (Sc...
method parseV3Map (line 236) | func (d *Definitions) parseV3Map(s *openapi_v3.Schema, path *Path) (Sche...
function parseV3Interface (line 275) | func parseV3Interface(def *yaml.Node) (interface{}, error) {
method parseV3BaseSchema (line 286) | func (d *Definitions) parseV3BaseSchema(s *openapi_v3.Schema, path *Path...
function SpecificationExtensionToMap (line 304) | func SpecificationExtensionToMap(e []*openapi_v3.NamedAny) map[string]in...
FILE: pkg/util/proto/openapi.go
constant Integer (line 27) | Integer = "integer"
constant Number (line 28) | Number = "number"
constant String (line 29) | String = "string"
constant Boolean (line 30) | Boolean = "boolean"
constant array (line 34) | array = "array"
constant object (line 35) | object = "object"
type Models (line 40) | type Models interface
type SchemaVisitor (line 53) | type SchemaVisitor interface
type SchemaVisitorArbitrary (line 64) | type SchemaVisitorArbitrary interface
type Schema (line 70) | type Schema interface
type Path (line 87) | type Path struct
method Get (line 96) | func (p *Path) Get() []string {
method Len (line 106) | func (p *Path) Len() int {
method String (line 110) | func (p *Path) String() string {
method ArrayPath (line 115) | func (p *Path) ArrayPath(i int) Path {
method FieldPath (line 123) | func (p *Path) FieldPath(field string) Path {
function NewPath (line 92) | func NewPath(key string) Path {
type BaseSchema (line 131) | type BaseSchema struct
method GetDescription (line 139) | func (b *BaseSchema) GetDescription() string {
method GetExtensions (line 143) | func (b *BaseSchema) GetExtensions() map[string]interface{} {
method GetDefault (line 147) | func (b *BaseSchema) GetDefault() interface{} {
method GetPath (line 151) | func (b *BaseSchema) GetPath() *Path {
type Array (line 156) | type Array struct
method Accept (line 164) | func (a *Array) Accept(v SchemaVisitor) {
method GetName (line 168) | func (a *Array) GetName() string {
type Kind (line 176) | type Kind struct
method Accept (line 189) | func (k *Kind) Accept(v SchemaVisitor) {
method GetName (line 193) | func (k *Kind) GetName() string {
method IsRequired (line 202) | func (k *Kind) IsRequired(field string) bool {
method Keys (line 212) | func (k *Kind) Keys() []string {
type Map (line 223) | type Map struct
method Accept (line 231) | func (m *Map) Accept(v SchemaVisitor) {
method GetName (line 235) | func (m *Map) GetName() string {
type Primitive (line 241) | type Primitive struct
method Accept (line 251) | func (p *Primitive) Accept(v SchemaVisitor) {
method GetName (line 255) | func (p *Primitive) GetName() string {
type Arbitrary (line 263) | type Arbitrary struct
method Accept (line 269) | func (a *Arbitrary) Accept(v SchemaVisitor) {
method GetName (line 275) | func (a *Arbitrary) GetName() string {
type Reference (line 280) | type Reference interface
FILE: pkg/util/proto/openapi_test.go
function loadV18Models (line 35) | func loadV18Models(t *testing.T) proto.Models {
function loadV18DeploymentModel (line 49) | func loadV18DeploymentModel(t *testing.T) (proto.Models, proto.Schema, *...
function TestV18Deployment (line 63) | func TestV18Deployment(t *testing.T) {
function TestV111Deployment (line 269) | func TestV111Deployment(t *testing.T) {
function TestV111ControllerRevision (line 298) | func TestV111ControllerRevision(t *testing.T) {
function TestSubjectAccessReview (line 355) | func TestSubjectAccessReview(t *testing.T) {
function TestPath (line 457) | func TestPath(t *testing.T) {
function loadV3Deployment (line 496) | func loadV3Deployment(t *testing.T) *proto.Kind {
function TestV3Deployment (line 517) | func TestV3Deployment(t *testing.T) {
function TestV3GVKExtension (line 684) | func TestV3GVKExtension(t *testing.T) {
FILE: pkg/util/proto/testing/openapi.go
type Fake (line 28) | type Fake struct
method OpenAPISchema (line 37) | func (f *Fake) OpenAPISchema() (*openapi_v2.Document, error) {
type Empty (line 54) | type Empty struct
method OpenAPISchema (line 56) | func (Empty) OpenAPISchema() (*openapi_v2.Document, error) {
FILE: pkg/util/proto/testing/openapi_v3.go
type FakeV3 (line 27) | type FakeV3 struct
method OpenAPIV3Schema (line 35) | func (f *FakeV3) OpenAPIV3Schema(groupVersion string) (*openapi_v3.Doc...
FILE: pkg/util/proto/validation/errors.go
type errors (line 23) | type errors struct
method Errors (line 27) | func (e *errors) Errors() []error {
method AppendErrors (line 31) | func (e *errors) AppendErrors(err ...error) {
type ValidationError (line 35) | type ValidationError struct
method Error (line 40) | func (e ValidationError) Error() string {
type InvalidTypeError (line 44) | type InvalidTypeError struct
method Error (line 50) | func (e InvalidTypeError) Error() string {
type MissingRequiredFieldError (line 54) | type MissingRequiredFieldError struct
method Error (line 59) | func (e MissingRequiredFieldError) Error() string {
type UnknownFieldError (line 63) | type UnknownFieldError struct
method Error (line 68) | func (e UnknownFieldError) Error() string {
type InvalidObjectTypeError (line 72) | type InvalidObjectTypeError struct
method Error (line 77) | func (e InvalidObjectTypeError) Error() string {
FILE: pkg/util/proto/validation/types.go
type validationItem (line 26) | type validationItem interface
type baseItem (line 33) | type baseItem struct
method Errors (line 39) | func (item *baseItem) Errors() []error {
method AddValidationError (line 45) | func (item *baseItem) AddValidationError(err error) {
method AddError (line 50) | func (item *baseItem) AddError(err error) {
method CopyErrors (line 56) | func (item *baseItem) CopyErrors(errs []error) {
method Path (line 61) | func (item *baseItem) Path() *proto.Path {
type mapItem (line 66) | type mapItem struct
method sortedKeys (line 72) | func (item *mapItem) sortedKeys() []string {
method VisitPrimitive (line 83) | func (item *mapItem) VisitPrimitive(schema *proto.Primitive) {
method VisitArray (line 87) | func (item *mapItem) VisitArray(schema *proto.Array) {
method VisitMap (line 91) | func (item *mapItem) VisitMap(schema *proto.Map) {
method VisitKind (line 103) | func (item *mapItem) VisitKind(schema *proto.Kind) {
method VisitArbitrary (line 130) | func (item *mapItem) VisitArbitrary(schema *proto.Arbitrary) {
method VisitReference (line 133) | func (item *mapItem) VisitReference(schema proto.Reference) {
type arrayItem (line 139) | type arrayItem struct
method VisitPrimitive (line 147) | func (item *arrayItem) VisitPrimitive(schema *proto.Primitive) {
method VisitArray (line 151) | func (item *arrayItem) VisitArray(schema *proto.Array) {
method VisitMap (line 168) | func (item *arrayItem) VisitMap(schema *proto.Map) {
method VisitKind (line 172) | func (item *arrayItem) VisitKind(schema *proto.Kind) {
method VisitArbitrary (line 176) | func (item *arrayItem) VisitArbitrary(schema *proto.Arbitrary) {
method VisitReference (line 179) | func (item *arrayItem) VisitReference(schema proto.Reference) {
type primitiveItem (line 185) | type primitiveItem struct
method VisitPrimitive (line 194) | func (item *primitiveItem) VisitPrimitive(schema *proto.Primitive) {
method VisitArray (line 224) | func (item *primitiveItem) VisitArray(schema *proto.Array) {
method VisitMap (line 228) | func (item *primitiveItem) VisitMap(schema *proto.Map) {
method VisitKind (line 232) | func (item *primitiveItem) VisitKind(schema *proto.Kind) {
method VisitArbitrary (line 236) | func (item *primitiveItem) VisitArbitrary(schema *proto.Arbitrary) {
method VisitReference (line 239) | func (item *primitiveItem) VisitReference(schema proto.Reference) {
function itemFactory (line 245) | func itemFactory(path proto.Path, v interface{}) (validationItem, error) {
FILE: pkg/util/proto/validation/validation.go
function ValidateModel (line 23) | func ValidateModel(obj interface{}, schema proto.Schema, name string) []...
FILE: pkg/util/proto/validation/validation_test.go
function Validate (line 34) | func Validate(models proto.Models, model string, data string) []error {
function ValidateObj (line 44) | func ValidateObj(models proto.Models, model string, obj interface{}) []e...
function loadModels (line 53) | func loadModels(t *testing.T) proto.Models {
function TestResourceValidation (line 66) | func TestResourceValidation(t *testing.T) {
FILE: pkg/util/sets/empty.go
type Empty (line 27) | type Empty struct
FILE: pkg/util/sets/string.go
type String (line 31) | type String
method Insert (line 53) | func (s String) Insert(items ...string) {
method Delete (line 60) | func (s String) Delete(items ...string) {
method Has (line 67) | func (s String) Has(item string) bool {
method HasAll (line 73) | func (s String) HasAll(items ...string) bool {
method HasAny (line 83) | func (s String) HasAny(items ...string) bool {
method Difference (line 98) | func (s String) Difference(s2 String) String {
method Union (line 114) | func (s1 String) Union(s2 String) String {
method Intersection (line 130) | func (s1 String) Intersection(s2 String) String {
method IsSuperset (line 149) | func (s1 String) IsSuperset(s2 String) bool {
method Equal (line 161) | func (s1 String) Equal(s2 String) bool {
method List (line 172) | func (s String) List() []string {
method UnsortedList (line 182) | func (s String) UnsortedList() []string {
method PopAny (line 191) | func (s String) PopAny() (string, bool) {
method Len (line 201) | func (s String) Len() int {
function NewString (line 34) | func NewString(items ...string) String {
function StringKeySet (line 42) | func StringKeySet(theMap interface{}) String {
type sortableSliceOfString (line 165) | type sortableSliceOfString
method Len (line 167) | func (s sortableSliceOfString) Len() int { return len(s) }
method Less (line 168) | func (s sortableSliceOfString) Less(i, j int) bool { return lessString...
method Swap (line 169) | func (s sortableSliceOfString) Swap(i, j int) { s[i], s[j] = s[j]...
function lessString (line 205) | func lessString(lhs, rhs string) bool {
FILE: pkg/util/trie.go
type Trie (line 20) | type Trie struct
method Add (line 39) | func (t *Trie) Add(v string) {
method HasPrefix (line 57) | func (t *Trie) HasPrefix(v string) bool {
method GetPrefix (line 63) | func (t *Trie) GetPrefix(v string) (string, bool) {
function NewTrie (line 27) | func NewTrie(list []string) Trie {
FILE: pkg/util/util.go
function ToCanonicalName (line 42) | func ToCanonicalName(name string) string {
function ToRESTFriendlyName (line 58) | func ToRESTFriendlyName(name string) string {
type OpenAPICanonicalTypeNamer (line 91) | type OpenAPICanonicalTypeNamer interface
type OpenAPIModelNamer (line 99) | type OpenAPIModelNamer interface
function GetCanonicalTypeName (line 105) | func GetCanonicalTypeName(model interface{}) string {
FILE: pkg/util/util_test.go
function TestCanonicalName (line 24) | func TestCanonicalName(t *testing.T) {
type TestType (line 42) | type TestType struct
function TestGetCanonicalTypeName (line 44) | func TestGetCanonicalTypeName(t *testing.T) {
FILE: pkg/validation/errors/api.go
type Error (line 22) | type Error interface
type apiError (line 27) | type apiError struct
method Error (line 32) | func (a *apiError) Error() string {
method Code (line 36) | func (a *apiError) Code() int32 {
function New (line 41) | func New(code int32, message string, args ...interface{}) Error {
FILE: pkg/validation/errors/api_test.go
function TestValidateName (line 23) | func TestValidateName(t *testing.T) {
FILE: pkg/validation/errors/headers.go
type Validation (line 18) | type Validation struct
method Error (line 28) | func (e *Validation) Error() string {
method Code (line 33) | func (e *Validation) Code() int32 {
method ValidateName (line 38) | func (e *Validation) ValidateName(name string) *Validation {
FILE: pkg/validation/errors/schema.go
constant invalidType (line 23) | invalidType = "%s is an invalid type name"
constant typeFail (line 24) | typeFail = "%s in %s must be of type %s"
constant typeFailWithData (line 25) | typeFailWithData = "%s in %s must be of type %s: %q"
constant typeFailWithError (line 26) | typeFailWithError = "%s in %s must be of type %s, because: %s"
constant requiredFail (line 27) | requiredFail = "%s in %s is required"
constant tooLongMessage (line 28) | tooLongMessage = "%s in %s should be at most %d chars long"
constant tooShortMessage (line 29) | tooShortMessage = "%s in %s should be at least %d chars long"
constant patternFail (line 30) | patternFail = "%s in %s should match '%s'"
constant enumFail (line 31) | enumFail = "%s in %s should be one of %v"
constant multipleOfFail (line 32) | multipleOfFail = "%s in %s should be a multiple of %v"
constant maxIncFail (line 33) | maxIncFail = "%s in %s should be less than or equal to %v"
constant maxExcFail (line 34) | maxExcFail = "%s in %s should be less than %v"
constant minIncFail (line 35) | minIncFail = "%s in %s should be greater than or equal to...
constant minExcFail (line 36) | minExcFail = "%s in %s should be greater than %v"
constant uniqueFail (line 37) | uniqueFail = "%s in %s shouldn't contain duplicates"
constant maxItemsFail (line 38) | maxItemsFail = "%s in %s should have at most %d items"
constant minItemsFail (line 39) | minItemsFail = "%s in %s should have at least %d items"
constant typeFailNoIn (line 40) | typeFailNoIn = "%s must be of type %s"
constant typeFailWithDataNoIn (line 41) | typeFailWithDataNoIn = "%s must be of type %s: %q"
constant typeFailWithErrorNoIn (line 42) | typeFailWithErrorNoIn = "%s must be of type %s, because: %s"
constant requiredFailNoIn (line 43) | requiredFailNoIn = "%s is required"
constant tooLongMessageNoIn (line 44) | tooLongMessageNoIn = "%s should be at most %d chars long"
constant tooShortMessageNoIn (line 45) | tooShortMessageNoIn = "%s should be at least %d chars long"
constant patternFailNoIn (line 46) | patternFailNoIn = "%s should match '%s'"
constant enumFailNoIn (line 47) | enumFailNoIn = "%s should be one of %v"
constant multipleOfFailNoIn (line 48) | multipleOfFailNoIn = "%s should be a multiple of %v"
constant maxIncFailNoIn (line 49) | maxIncFailNoIn = "%s should be less than or equal to %v"
constant maxExcFailNoIn (line 50) | maxExcFailNoIn = "%s should be less than %v"
constant minIncFailNoIn (line 51) | minIncFailNoIn = "%s should be greater than or equal to %v"
constant minExcFailNoIn (line 52) | minExcFailNoIn = "%s should be greater than %v"
constant uniqueFailNoIn (line 53) | uniqueFailNoIn = "%s shouldn't contain duplicates"
constant maxItemsFailNoIn (line 54) | maxItemsFailNoIn = "%s should have at most %d items"
constant minItemsFailNoIn (line 55) | minItemsFailNoIn = "%s should have at least %d items"
constant noAdditionalItems (line 56) | noAdditionalItems = "%s in %s can't have additional items"
constant noAdditionalItemsNoIn (line 57) | noAdditionalItemsNoIn = "%s can't have additional items"
constant tooFewProperties (line 58) | tooFewProperties = "%s in %s should have at least %d properties"
constant tooFewPropertiesNoIn (line 59) | tooFewPropertiesNoIn = "%s should have at least %d properties"
constant tooManyProperties (line 60) | tooManyProperties = "%s in %s should have at most %d properties"
constant tooManyPropertiesNoIn (line 61) | tooManyPropertiesNoIn = "%s should have at most %d properties"
constant unallowedProperty (line 62) | unallowedProperty = "%s.%s in %s is a forbidden property"
constant unallowedPropertyNoIn (line 63) | unallowedPropertyNoIn = "%s.%s is a forbidden property"
constant failedAllPatternProps (line 64) | failedAllPatternProps = "%s.%s in %s failed all pattern properties"
constant failedAllPatternPropsNoIn (line 65) | failedAllPatternPropsNoIn = "%s.%s failed all pattern properties"
constant multipleOfMustBePositive (line 66) | multipleOfMustBePositive = "factor MultipleOf declared for %s must be p...
constant CompositeErrorCode (line 74) | CompositeErrorCode = 422
constant InvalidTypeCode (line 76) | InvalidTypeCode = 600 + iota
constant RequiredFailCode (line 77) | RequiredFailCode
constant TooLongFailCode (line 78) | TooLongFailCode
constant TooShortFailCode (line 79) | TooShortFailCode
constant PatternFailCode (line 80) | PatternFailCode
constant EnumFailCode (line 81) | EnumFailCode
constant MultipleOfFailCode (line 82) | MultipleOfFailCode
constant MaxFailCode (line 83) | MaxFailCode
constant MinFailCode (line 84) | MinFailCode
constant UniqueFailCode (line 85) | UniqueFailCode
constant MaxItemsFailCode (line 86) | MaxItemsFailCode
constant MinItemsFailCode (line 87) | MinItemsFailCode
constant NoAdditionalItemsCode (line 88) | NoAdditionalItemsCode
constant TooFewPropertiesCode (line 89) | TooFewPropertiesCode
constant TooManyPropertiesCode (line 90) | TooManyPropertiesCode
constant UnallowedPropertyCode (line 91) | UnallowedPropertyCode
constant FailedAllPatternPropsCode (line 92) | FailedAllPatternPropsCode
constant MultipleOfMustBePositiveCode (line 93) | MultipleOfMustBePositiveCode
type CompositeError (line 97) | type CompositeError struct
method Code (line 104) | func (c *CompositeError) Code() int32 {
method Error (line 108) | func (c *CompositeError) Error() string {
function CompositeValidationError (line 120) | func CompositeValidationError(errors ...error) *CompositeError {
function FailedAllPatternProperties (line 129) | func FailedAllPatternProperties(name, in, key string) *Validation {
function PropertyNotAllowed (line 144) | func PropertyNotAllowed(name, in, key string) *Validation {
function TooFewProperties (line 159) | func TooFewProperties(name, in string, minProperties, size int64) *Valid...
function TooManyProperties (line 175) | func TooManyProperties(name, in string, maxProperties, size int64) *Vali...
function AdditionalItemsNotAllowed (line 191) | func AdditionalItemsNotAllowed(name, in string) *Validation {
function InvalidCollectionFormat (line 205) | func InvalidCollectionFormat(name, in, format string) *Validation {
function InvalidTypeName (line 216) | func InvalidTypeName(typeName string) *Validation {
function InvalidType (line 225) | func InvalidType(name, in, typeName string, value interface{}) *Validati...
function DuplicateItems (line 259) | func DuplicateItems(name, in string) *Validation {
function TooManyItems (line 273) | func TooManyItems(name, in string, max int64, value interface{}) *Valida...
function TooFewItems (line 290) | func TooFewItems(name, in string, min int64, value interface{}) *Validat...
function ExceedsMaximumInt (line 306) | func ExceedsMaximumInt(name, in string, max int64, exclusive bool, value...
function ExceedsMaximumUint (line 331) | func ExceedsMaximumUint(name, in string, max uint64, exclusive bool, val...
function ExceedsMaximum (line 356) | func ExceedsMaximum(name, in string, max float64, exclusive bool, value ...
function ExceedsMinimumInt (line 381) | func ExceedsMinimumInt(name, in string, min int64, exclusive bool, value...
function ExceedsMinimumUint (line 406) | func ExceedsMinimumUint(name, in string, min uint64, exclusive bool, val...
function ExceedsMinimum (line 431) | func ExceedsMinimum(name, in string, min float64, exclusive bool, value ...
function NotMultipleOf (line 456) | func NotMultipleOf(name, in string, multiple, value interface{}) *Valida...
function EnumFail (line 473) | func EnumFail(name, in string, value interface{}, values []interface{}) ...
function Required (line 492) | func Required(name, in string) *Validation {
function TooLong (line 508) | func TooLong(name, in string, max int64, value interface{}) *Validation {
function TooShort (line 526) | func TooShort(name, in string, min int64, value interface{}) *Validation {
function FailedPattern (line 546) | func FailedPattern(name, in, pattern string, value interface{}) *Validat...
function MultipleOfMustBePositive (line 565) | func MultipleOfMustBePositive(name, in string, factor interface{}) *Vali...
FILE: pkg/validation/errors/schema_test.go
function TestSchemaErrors (line 25) | func TestSchemaErrors(t *testing.T) {
FILE: pkg/validation/spec/contact_info.go
type ContactInfo (line 20) | type ContactInfo struct
FILE: pkg/validation/spec/contact_info_test.go
constant contactInfoJSON (line 21) | contactInfoJSON = `{"name":"wordnik api team","url":"http://developer.wo...
constant contactInfoYAML (line 22) | contactInfoYAML = `name: wordnik api team
function TestIntegrationContactInfo (line 33) | func TestIntegrationContactInfo(t *testing.T) {
FILE: pkg/validation/spec/external_docs.go
type ExternalDocumentation (line 21) | type ExternalDocumentation struct
FILE: pkg/validation/spec/external_docs_test.go
function TestIntegrationExternalDocs (line 21) | func TestIntegrationExternalDocs(t *testing.T) {
FILE: pkg/validation/spec/gnostic.go
type GnosticCommonValidations (line 28) | type GnosticCommonValidations interface
method FromGnostic (line 43) | func (k *CommonValidations) FromGnostic(g GnosticCommonValidations) error {
type GnosticSimpleSchema (line 112) | type GnosticSimpleSchema interface
method FromGnostic (line 120) | func (k *SimpleSchema) FromGnostic(g GnosticSimpleSchema) error {
method FromGnostic (line 150) | func (k *Items) FromGnostic(g *openapi_v2.PrimitivesItems) error {
method FromGnostic (line 170) | func (k *VendorExtensible) FromGnostic(g []*openapi_v2.NamedAny) error {
method FromGnostic (line 196) | func (k *Refable) FromGnostic(g string) error {
method FromGnostic (line 200) | func (k *Ref) FromGnostic(g string) error {
method FromGnostic (line 233) | func (k *Swagger) FromGnostic(g *openapi_v2.Document) (ok bool, err erro...
method FromGnostic (line 252) | func (k *SwaggerProps) FromGnostic(g *openapi_v2.Document) (ok bool, err...
method FromGnostic (line 399) | func (k *Info) FromGnostic(g *openapi_v2.Info) (ok bool, err error) {
method FromGnostic (line 418) | func (k *InfoProps) FromGnostic(g *openapi_v2.Info) (ok bool, err error) {
method FromGnostic (line 452) | func (k *License) FromGnostic(g *openapi_v2.License) (ok bool, err error) {
method FromGnostic (line 471) | func (k *ContactInfo) FromGnostic(g *openapi_v2.Contact) (ok bool, err e...
method FromGnostic (line 493) | func (k *Paths) FromGnostic(g *openapi_v2.Paths) (ok bool, err error) {
method FromGnostic (line 524) | func (k *PathItem) FromGnostic(g *openapi_v2.PathItem) (ok bool, err err...
method FromGnostic (line 546) | func (k *PathItemProps) FromGnostic(g *openapi_v2.PathItem) (ok bool, er...
method FromGnostic (line 630) | func (k *Operation) FromGnostic(g *openapi_v2.Operation) (ok bool, err e...
method FromGnostic (line 650) | func (k *OperationProps) FromGnostic(g *openapi_v2.Operation) (ok bool, ...
method FromGnostic (line 726) | func (k *Responses) FromGnostic(g *openapi_v2.Responses) (ok bool, err e...
method FromGnostic (line 744) | func (k *ResponsesProps) FromGnostic(g *openapi_v2.Responses) (ok bool, ...
method FromGnostic (line 787) | func (k *Response) FromGnostic(g *openapi_v2.Response) (ok bool, err err...
method FromGnosticResponseValue (line 807) | func (k *Response) FromGnosticResponseValue(g *openapi_v2.ResponseValue)...
method FromGnostic (line 824) | func (k *ResponseProps) FromGnostic(g *openapi_v2.Response) (ok bool, er...
method FromGnostic (line 880) | func (k *Header) FromGnostic(g *openapi_v2.Header) (err error) {
method FromGnostic (line 904) | func (k *HeaderProps) FromGnostic(g *openapi_v2.Header) error {
method FromGnostic (line 917) | func (k *Parameter) FromGnostic(g *openapi_v2.Parameter) (ok bool, err e...
type GnosticCommonParamProps (line 1025) | type GnosticCommonParamProps interface
type GnosticCommonParamPropsBodyParameter (line 1032) | type GnosticCommonParamPropsBodyParameter interface
type GnosticCommonParamPropsFormData (line 1036) | type GnosticCommonParamPropsFormData interface
method FromGnostic (line 1040) | func (k *ParamProps) FromGnostic(g GnosticCommonParamProps) (ok bool, er...
method FromGnosticParametersItem (line 1067) | func (k *Parameter) FromGnosticParametersItem(g *openapi_v2.ParametersIt...
method FromGnostic (line 1090) | func (k *Schema) FromGnostic(g *openapi_v2.Schema) (ok bool, err error) {
method FromGnosticSchemaItem (line 1279) | func (k *Schema) FromGnosticSchemaItem(g *openapi_v2.SchemaItem) (ok boo...
method FromGnostic (line 1338) | func (k SecurityDefinitions) FromGnostic(g *openapi_v2.SecurityDefinitio...
type GnosticCommonSecurityDefinition (line 1353) | type GnosticCommonSecurityDefinition interface
method FromGnostic (line 1358) | func (k *SecuritySchemeProps) FromGnostic(g GnosticCommonSecurityDefinit...
method FromGnostic (line 1401) | func (k *SecurityScheme) FromGnostic(g *openapi_v2.SecurityDefinitionsIt...
method FromGnostic (line 1462) | func (k *Tag) FromGnostic(g *openapi_v2.Tag) (ok bool, err error) {
method FromGnostic (line 1481) | func (k *TagProps) FromGnostic(g *openapi_v2.Tag) (ok bool, err error) {
method FromGnostic (line 1503) | func (k *ExternalDocumentation) FromGnostic(g *openapi_v2.ExternalDocs) ...
FILE: pkg/validation/spec/gnostic_test.go
function gnosticCommonTest (line 38) | func gnosticCommonTest(t testing.TB, fuzzer *randfill.Filler) {
function TestGnosticConversionSmallDeterministic (line 70) | func TestGnosticConversionSmallDeterministic(t *testing.T) {
function TestGnosticConversionSmallDeterministic2 (line 81) | func TestGnosticConversionSmallDeterministic2(t *testing.T) {
function TestGnosticConversionSmallDeterministic3 (line 94) | func TestGnosticConversionSmallDeterministic3(t *testing.T) {
function TestGnosticConversionSmallDeterministic4 (line 107) | func TestGnosticConversionSmallDeterministic4(t *testing.T) {
function TestGnosticConversionSmallDeterministic5 (line 120) | func TestGnosticConversionSmallDeterministic5(t *testing.T) {
function TestGnosticConversionSmallDeterministic6 (line 133) | func TestGnosticConversionSmallDeterministic6(t *testing.T) {
function TestGnosticConversionSmallDeterministic7 (line 146) | func TestGnosticConversionSmallDeterministic7(t *testing.T) {
function TestGnosticConversionSmallRandom (line 161) | func TestGnosticConversionSmallRandom(t *testing.T) {
function TestGnosticConversionMediumDeterministic (line 178) | func TestGnosticConversionMediumDeterministic(t *testing.T) {
function TestGnosticConversionLargeDeterministic (line 189) | func TestGnosticConversionLargeDeterministic(t *testing.T) {
function TestGnosticConversionLargeRandom (line 200) | func TestGnosticConversionLargeRandom(t *testing.T) {
function BenchmarkGnosticConversion (line 217) | func BenchmarkGnosticConversion(b *testing.B) {
function TestSecurityDefinitionVariants (line 298) | func TestSecurityDefinitionVariants(t *testing.T) {
function TestParamVariants (line 376) | func TestParamVariants(t *testing.T) {
function TestCommonDataLoss (line 450) | func TestCommonDataLoss(t *testing.T) {
function TestBadStatusCode (line 551) | func TestBadStatusCode(t *testing.T) {
FILE: pkg/validation/spec/header.go
constant jsonArray (line 26) | jsonArray = "array"
type HeaderProps (line 30) | type HeaderProps struct
type Header (line 37) | type Header struct
method MarshalJSON (line 45) | func (h Header) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 68) | func (h Header) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv...
method UnmarshalJSON (line 83) | func (h *Header) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 100) | func (h *Header) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *...
FILE: pkg/validation/spec/header_test.go
function float64Ptr (line 28) | func float64Ptr(f float64) *float64 {
function int64Ptr (line 31) | func int64Ptr(f int64) *int64 {
constant headerJSON (line 64) | headerJSON = `{
function TestIntegrationHeader (line 93) | func TestIntegrationHeader(t *testing.T) {
function TestHeaderSerialization (line 106) | func TestHeaderSerialization(t *testing.T) {
function TestHeaderRoundTrip (line 123) | func TestHeaderRoundTrip(t *testing.T) {
FILE: pkg/validation/spec/info.go
type Extensions (line 27) | type Extensions
method Add (line 30) | func (e Extensions) Add(key string, value interface{}) {
method GetString (line 36) | func (e Extensions) GetString(key string) (string, bool) {
method GetBool (line 45) | func (e Extensions) GetBool(key string) (bool, bool) {
method GetStringSlice (line 54) | func (e Extensions) GetStringSlice(key string) ([]string, bool) {
method GetObject (line 76) | func (e Extensions) GetObject(key string, out interface{}) error {
method sanitizeWithExtra (line 92) | func (e Extensions) sanitizeWithExtra() (extra map[string]any) {
type VendorExtensible (line 106) | type VendorExtensible struct
method AddExtension (line 111) | func (v *VendorExtensible) AddExtension(key string, value interface{}) {
method MarshalJSON (line 122) | func (v VendorExtensible) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 134) | func (v *VendorExtensible) UnmarshalJSON(data []byte) error {
type InfoProps (line 152) | type InfoProps struct
type Info (line 165) | type Info struct
method MarshalJSON (line 171) | func (i Info) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 186) | func (i Info) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2....
method UnmarshalJSON (line 197) | func (i *Info) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 208) | func (i *Info) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *js...
FILE: pkg/validation/spec/info_test.go
constant infoJSON (line 26) | infoJSON = `{
function TestIntegrationInfo_Serialize (line 59) | func TestIntegrationInfo_Serialize(t *testing.T) {
function TestIntegrationInfo_Deserialize (line 66) | func TestIntegrationInfo_Deserialize(t *testing.T) {
function TestInfoRoundTrip (line 74) | func TestInfoRoundTrip(t *testing.T) {
FILE: pkg/validation/spec/items.go
constant jsonRef (line 26) | jsonRef = "$ref"
type SimpleSchema (line 30) | type SimpleSchema struct
type simpleSchemaOmitZero (line 42) | type simpleSchemaOmitZero struct
type CommonValidations (line 53) | type CommonValidations struct
type commonValidationsOmitZero (line 70) | type commonValidationsOmitZero struct
type Items (line 89) | type Items struct
method UnmarshalJSON (line 97) | func (i *Items) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 125) | func (i *Items) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *j...
method MarshalJSON (line 145) | func (i Items) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 168) | func (i Items) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2...
FILE: pkg/validation/spec/items_test.go
constant itemsJSON (line 53) | itemsJSON = `{
function TestIntegrationItems (line 76) | func TestIntegrationItems(t *testing.T) {
function TestItemsRoundTrip (line 85) | func TestItemsRoundTrip(t *testing.T) {
FILE: pkg/validation/spec/license.go
type License (line 20) | type License struct
FILE: pkg/validation/spec/license_test.go
function TestIntegrationLicense (line 19) | func TestIntegrationLicense(t *testing.T) {
FILE: pkg/validation/spec/operation.go
type OperationProps (line 30) | type OperationProps struct
method MarshalJSON (line 67) | func (op OperationProps) MarshalJSON() ([]byte, error) {
type operationPropsOmitZero (line 47) | type operationPropsOmitZero struct
type Operation (line 90) | type Operation struct
method UnmarshalJSON (line 96) | func (o *Operation) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 107) | func (o *Operation) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
method MarshalJSON (line 122) | func (o Operation) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 138) | func (o Operation) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *js...
FILE: pkg/validation/spec/operation_test.go
constant operationJSON (line 61) | operationJSON = `{
function TestIntegrationOperation (line 80) | func TestIntegrationOperation(t *testing.T) {
function TestOperationRoundtrip (line 89) | func TestOperationRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/parameter.go
type ParamProps (line 30) | type ParamProps struct
type paramPropsOmitZero (line 41) | type paramPropsOmitZero struct
type Parameter (line 81) | type Parameter struct
method UnmarshalJSON (line 90) | func (p *Parameter) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 110) | func (p *Parameter) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
method MarshalJSON (line 131) | func (p Parameter) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 158) | func (p Parameter) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *js...
FILE: pkg/validation/spec/parameters_test.go
function TestIntegrationParameter (line 94) | func TestIntegrationParameter(t *testing.T) {
function TestParameterRoundtrip (line 103) | func TestParameterRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/path_item.go
type PathItemProps (line 26) | type PathItemProps struct
type PathItem (line 43) | type PathItem struct
method UnmarshalJSON (line 50) | func (p *PathItem) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 64) | func (p *PathItem) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec...
method MarshalJSON (line 83) | func (p PathItem) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 103) | func (p PathItem) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jso...
FILE: pkg/validation/spec/path_item_test.go
constant pathItemJSON (line 63) | pathItemJSON = `{
function TestIntegrationPathItem (line 76) | func TestIntegrationPathItem(t *testing.T) {
function TestPathItemRoundTrip (line 85) | func TestPathItemRoundTrip(t *testing.T) {
FILE: pkg/validation/spec/paths.go
type Paths (line 33) | type Paths struct
method UnmarshalJSON (line 39) | func (p *Paths) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 73) | func (p *Paths) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *j...
method MarshalJSON (line 128) | func (p Paths) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 151) | func (p Paths) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2...
FILE: pkg/validation/spec/paths_test.go
constant pathsJSON (line 35) | pathsJSON = `{"x-framework":"go-swagger","/":{"$ref":"cats"}}`
constant pathsJSONInvalidKey (line 36) | pathsJSONInvalidKey = `{"x-framework":"go-swagger","not-path-nor-extensi...
function TestIntegrationPaths (line 38) | func TestIntegrationPaths(t *testing.T) {
function TestPathsRoundtrip (line 51) | func TestPathsRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/ref.go
type Refable (line 25) | type Refable struct
method MarshalJSON (line 30) | func (r Refable) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 35) | func (r *Refable) UnmarshalJSON(d []byte) error {
type Ref (line 40) | type Ref struct
method RemoteURI (line 45) | func (r *Ref) RemoteURI() string {
method Inherits (line 57) | func (r *Ref) Inherits(child Ref) (*Ref, error) {
method MarshalJSON (line 82) | func (r Ref) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 95) | func (r *Ref) UnmarshalJSON(d []byte) error {
method fromMap (line 103) | func (r *Ref) fromMap(v map[string]interface{}) error {
function NewRef (line 67) | func NewRef(refURI string) (Ref, error) {
function MustCreateRef (line 77) | func MustCreateRef(refURI string) Ref {
FILE: pkg/validation/spec/ref_test.go
function TestCloneRef (line 27) | func TestCloneRef(t *testing.T) {
FILE: pkg/validation/spec/response.go
type ResponseProps (line 26) | type ResponseProps struct
type responsePropsOmitZero (line 35) | type responsePropsOmitZero struct
type Response (line 45) | type Response struct
method UnmarshalJSON (line 52) | func (r *Response) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 70) | func (r *Response) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec...
method MarshalJSON (line 90) | func (r Response) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 109) | func (r Response) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jso...
function NewResponse (line 122) | func NewResponse() *Response {
function ResponseRef (line 127) | func ResponseRef(url string) *Response {
FILE: pkg/validation/spec/response_test.go
constant responseJSON (line 39) | responseJSON = `{
function TestIntegrationResponse (line 48) | func TestIntegrationResponse(t *testing.T) {
function TestResponseRoundtrip (line 57) | func TestResponseRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/responses.go
type Responses (line 41) | type Responses struct
method UnmarshalJSON (line 47) | func (r *Responses) UnmarshalJSON(data []byte) error {
method MarshalJSON (line 65) | func (r Responses) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 81) | func (r Responses) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *js...
method UnmarshalNextJSON (line 153) | func (r *Responses) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, de...
type ResponsesProps (line 103) | type ResponsesProps struct
method MarshalJSON (line 109) | func (r ResponsesProps) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 121) | func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
FILE: pkg/validation/spec/responses_test.go
function TestResponsesRoundtrip (line 26) | func TestResponsesRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/schema.go
function BooleanProperty (line 29) | func BooleanProperty() *Schema {
function BoolProperty (line 34) | func BoolProperty() *Schema { return BooleanProperty() }
function StringProperty (line 37) | func StringProperty() *Schema {
function CharProperty (line 42) | func CharProperty() *Schema {
function Float64Property (line 47) | func Float64Property() *Schema {
function Float32Property (line 52) | func Float32Property() *Schema {
function Int8Property (line 57) | func Int8Property() *Schema {
function Int16Property (line 62) | func Int16Property() *Schema {
function Int32Property (line 67) | func Int32Property() *Schema {
function Int64Property (line 72) | func Int64Property() *Schema {
function StrFmtProperty (line 77) | func StrFmtProperty(format string) *Schema {
function DateProperty (line 82) | func DateProperty() *Schema {
function DateTimeProperty (line 87) | func DateTimeProperty() *Schema {
function MapProperty (line 92) | func MapProperty(property *Schema) *Schema {
function RefProperty (line 98) | func RefProperty(name string) *Schema {
function RefSchema (line 103) | func RefSchema(name string) *Schema {
function ArrayProperty (line 108) | func ArrayProperty(items *Schema) *Schema {
function ComposedSchema (line 116) | func ComposedSchema(schemas ...Schema) *Schema {
type SchemaURL (line 123) | type SchemaURL
method MarshalJSON (line 126) | func (r SchemaURL) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 135) | func (r *SchemaURL) UnmarshalJSON(data []byte) error {
method fromMap (line 143) | func (r *SchemaURL) fromMap(v map[string]interface{}) error {
type SchemaProps (line 161) | type SchemaProps struct
type schemaPropsOmitZero (line 201) | type schemaPropsOmitZero struct
type SwaggerSchemaProps (line 240) | type SwaggerSchemaProps struct
type swaggerSchemaPropsOmitZero (line 249) | type swaggerSchemaPropsOmitZero struct
type Schema (line 263) | type Schema struct
method WithID (line 271) | func (s *Schema) WithID(id string) *Schema {
method WithTitle (line 277) | func (s *Schema) WithTitle(title string) *Schema {
method WithDescription (line 283) | func (s *Schema) WithDescription(description string) *Schema {
method WithProperties (line 289) | func (s *Schema) WithProperties(schemas map[string]Schema) *Schema {
method SetProperty (line 295) | func (s *Schema) SetProperty(name string, schema Schema) *Schema {
method WithAllOf (line 304) | func (s *Schema) WithAllOf(schemas ...Schema) *Schema {
method WithMaxProperties (line 310) | func (s *Schema) WithMaxProperties(max int64) *Schema {
method WithMinProperties (line 316) | func (s *Schema) WithMinProperties(min int64) *Schema {
method Typed (line 322) | func (s *Schema) Typed(tpe, format string) *Schema {
method AddType (line 329) | func (s *Schema) AddType(tpe, format string) *Schema {
method AsNullable (line 338) | func (s *Schema) AsNullable() *Schema {
method CollectionOf (line 344) | func (s *Schema) CollectionOf(items Schema) *Schema {
method WithDefault (line 351) | func (s *Schema) WithDefault(defaultValue interface{}) *Schema {
method WithRequired (line 357) | func (s *Schema) WithRequired(items ...string) *Schema {
method AddRequired (line 363) | func (s *Schema) AddRequired(items ...string) *Schema {
method WithMaxLength (line 369) | func (s *Schema) WithMaxLength(max int64) *Schema {
method WithMinLength (line 375) | func (s *Schema) WithMinLength(min int64) *Schema {
method WithPattern (line 381) | func (s *Schema) WithPattern(pattern string) *Schema {
method WithMultipleOf (line 387) | func (s *Schema) WithMultipleOf(number float64) *Schema {
method WithMaximum (line 393) | func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema {
method WithMinimum (line 400) | func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema {
method WithEnum (line 407) | func (s *Schema) WithEnum(values ...interface{}) *Schema {
method WithMaxItems (line 413) | func (s *Schema) WithMaxItems(size int64) *Schema {
method WithMinItems (line 419) | func (s *Schema) WithMinItems(size int64) *Schema {
method UniqueValues (line 425) | func (s *Schema) UniqueValues() *Schema {
method AllowDuplicates (line 431) | func (s *Schema) AllowDuplicates() *Schema {
method AddToAllOf (line 437) | func (s *Schema) AddToAllOf(schemas ...Schema) *Schema {
method WithDiscriminator (line 443) | func (s *Schema) WithDiscriminator(discriminator string) *Schema {
method AsReadOnly (line 449) | func (s *Schema) AsReadOnly() *Schema {
method AsWritable (line 455) | func (s *Schema) AsWritable() *Schema {
method WithExample (line 461) | func (s *Schema) WithExample(example interface{}) *Schema {
method WithExternalDocs (line 470) | func (s *Schema) WithExternalDocs(description, url string) *Schema {
method MarshalJSON (line 485) | func (s Schema) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 520) | func (s Schema) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv...
method UnmarshalJSON (line 546) | func (s *Schema) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 598) | func (s *Schema) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *...
FILE: pkg/validation/spec/schema_test.go
function TestSchema (line 146) | func TestSchema(t *testing.T) {
function TestSchemaRoundtrip (line 203) | func TestSchemaRoundtrip(t *testing.T) {
function BenchmarkSchemaUnmarshal (line 240) | func BenchmarkSchemaUnmarshal(b *testing.B) {
FILE: pkg/validation/spec/security_scheme.go
type SecuritySchemeProps (line 26) | type SecuritySchemeProps struct
type SecurityScheme (line 42) | type SecurityScheme struct
method MarshalJSON (line 48) | func (s SecurityScheme) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 63) | func (s SecurityScheme) MarshalNextJSON(opts jsonv2.MarshalOptions, en...
method UnmarshalJSON (line 74) | func (s *SecurityScheme) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 81) | func (s *SecurityScheme) UnmarshalNextJSON(opts jsonv2.UnmarshalOption...
FILE: pkg/validation/spec/security_scheme_test.go
function TestSecuritySchemeRoundtrip (line 26) | func TestSecuritySchemeRoundtrip(t *testing.T) {
FILE: pkg/validation/spec/structs_test.go
function assertSerializeJSON (line 25) | func assertSerializeJSON(t testing.TB, actual interface{}, expected stri...
function derefTypeOf (line 33) | func derefTypeOf(expected interface{}) (tpe reflect.Type) {
function isPointed (line 41) | func isPointed(expected interface{}) (pointed bool) {
function assertParsesJSON (line 49) | func assertParsesJSON(t testing.TB, actual string, expected interface{})...
function TestSerialization_SerializeJSON (line 62) | func TestSerialization_SerializeJSON(t *testing.T) {
function TestSerialization_DeserializeJSON (line 78) | func TestSerialization_DeserializeJSON(t *testing.T) {
FILE: pkg/validation/spec/swagger.go
type Swagger (line 31) | type Swagger struct
method MarshalJSON (line 37) | func (s Swagger) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 53) | func (s Swagger) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *json...
method UnmarshalJSON (line 64) | func (s *Swagger) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 79) | func (s *Swagger) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec ...
type SwaggerProps (line 102) | type SwaggerProps struct
type Dependencies (line 122) | type Dependencies
type SchemaOrBool (line 125) | type SchemaOrBool struct
method MarshalJSON (line 134) | func (s SchemaOrBool) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 149) | func (s SchemaOrBool) MarshalNextJSON(opts jsonv2.MarshalOptions, enc ...
method UnmarshalJSON (line 161) | func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 181) | func (s *SchemaOrBool) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions,...
type SchemaOrStringArray (line 202) | type SchemaOrStringArray struct
method MarshalJSON (line 208) | func (s SchemaOrStringArray) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 222) | func (s SchemaOrStringArray) MarshalNextJSON(opts jsonv2.MarshalOption...
method UnmarshalJSON (line 233) | func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 259) | func (s *SchemaOrStringArray) UnmarshalNextJSON(opts jsonv2.UnmarshalO...
type Definitions (line 276) | type Definitions
type SecurityDefinitions (line 283) | type SecurityDefinitions
type StringOrArray (line 287) | type StringOrArray
method Contains (line 290) | func (s StringOrArray) Contains(value string) bool {
method UnmarshalJSON (line 300) | func (s *StringOrArray) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 335) | func (s *StringOrArray) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions...
method MarshalJSON (line 353) | func (s StringOrArray) MarshalJSON() ([]byte, error) {
type SchemaOrArray (line 362) | type SchemaOrArray struct
method Len (line 368) | func (s SchemaOrArray) Len() int {
method ContainsType (line 376) | func (s *SchemaOrArray) ContainsType(name string) bool {
method MarshalJSON (line 384) | func (s SchemaOrArray) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 395) | func (s SchemaOrArray) MarshalNextJSON(opts jsonv2.MarshalOptions, enc...
method UnmarshalJSON (line 403) | func (s *SchemaOrArray) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 429) | func (s *SchemaOrArray) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions...
FILE: pkg/validation/spec/swagger_test.go
constant specJSON (line 70) | specJSON = `{
function TestSwaggerSpec_Serialize (line 118) | func TestSwaggerSpec_Serialize(t *testing.T) {
function TestSwaggerSpec_Deserialize (line 131) | func TestSwaggerSpec_Deserialize(t *testing.T) {
function TestSwaggerRoundtrip (line 139) | func TestSwaggerRoundtrip(t *testing.T) {
function TestSwaggerSpec_Marshalv2Fuzzed (line 167) | func TestSwaggerSpec_Marshalv2Fuzzed(t *testing.T) {
function TestSwaggerSpec_Marshalv2FuzzedIsStable (line 200) | func TestSwaggerSpec_Marshalv2FuzzedIsStable(t *testing.T) {
function TestUnmarshalAdditionalProperties (line 232) | func TestUnmarshalAdditionalProperties(t *testing.T) {
function TestSwaggerSpec_ExperimentalUnmarshal (line 254) | func TestSwaggerSpec_ExperimentalUnmarshal(t *testing.T) {
function BenchmarkSwaggerSpec_ExperimentalUnmarshal (line 294) | func BenchmarkSwaggerSpec_ExperimentalUnmarshal(b *testing.B) {
function BenchmarkSwaggerSpec_ExperimentalMarshal (line 343) | func BenchmarkSwaggerSpec_ExperimentalMarshal(b *testing.B) {
FILE: pkg/validation/spec/tag.go
type TagProps (line 26) | type TagProps struct
type Tag (line 37) | type Tag struct
method MarshalJSON (line 43) | func (t Tag) MarshalJSON() ([]byte, error) {
method MarshalNextJSON (line 58) | func (t Tag) MarshalNextJSON(opts jsonv2.MarshalOptions, enc *jsonv2.E...
method UnmarshalJSON (line 69) | func (t *Tag) UnmarshalJSON(data []byte) error {
method UnmarshalNextJSON (line 80) | func (t *Tag) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *jso...
FILE: pkg/validation/spec/tag_test.go
function TestTagRoundtrip (line 26) | func TestTagRoundtrip(t *testing.T) {
FILE: pkg/validation/strfmt/bson.go
function init (line 21) | func init() {
function IsBSONObjectID (line 28) | func IsBSONObjectID(str string) bool {
type ObjectId (line 36) | type ObjectId
method MarshalText (line 48) | func (id ObjectId) MarshalText() ([]byte, error) {
method UnmarshalText (line 57) | func (id *ObjectId) UnmarshalText(data []byte) error { // validation i...
method String (line 71) | func (id ObjectId) String() string {
method MarshalJSON (line 76) | func (id ObjectId) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 81) | func (id *ObjectId) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 91) | func (id *ObjectId) DeepCopyInto(out *ObjectId) {
method DeepCopy (line 96) | func (id *ObjectId) DeepCopy() *ObjectId {
function NewObjectId (line 39) | func NewObjectId(hex string) ObjectId {
FILE: pkg/validation/strfmt/bson/objectid.go
type ObjectID (line 24) | type ObjectID
method Hex (line 30) | func (id ObjectID) Hex() string {
method String (line 34) | func (id ObjectID) String() string {
method IsZero (line 39) | func (id ObjectID) IsZero() bool {
method MarshalJSON (line 62) | func (id ObjectID) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 70) | func (id *ObjectID) UnmarshalJSON(b []byte) error {
function ObjectIDFromHex (line 45) | func ObjectIDFromHex(s string) (ObjectID, error) {
FILE: pkg/validation/strfmt/bson_test.go
function TestBSONObjectId_fullCycle (line 23) | func TestBSONObjectId_fullCycle(t *testing.T) {
function TestDeepCopyObjectId (line 42) | func TestDeepCopyObjectId(t *testing.T) {
FILE: pkg/validation/strfmt/date.go
function init (line 22) | func init() {
function IsDate (line 29) | func IsDate(str string) bool {
constant RFC3339FullDate (line 37) | RFC3339FullDate = "2006-01-02"
type Date (line 43) | type Date
method String (line 46) | func (d Date) String() string {
method UnmarshalText (line 51) | func (d *Date) UnmarshalText(text []byte) error {
method MarshalText (line 64) | func (d Date) MarshalText() ([]byte, error) {
method MarshalJSON (line 69) | func (d Date) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 74) | func (d *Date) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 91) | func (d *Date) DeepCopyInto(out *Date) {
method DeepCopy (line 96) | func (d *Date) DeepCopy() *Date {
FILE: pkg/validation/strfmt/date_test.go
function TestDate (line 24) | func TestDate(t *testing.T) {
function TestDate_IsDate (line 57) | func TestDate_IsDate(t *testing.T) {
function TestDeepCopyDate (line 82) | func TestDeepCopyDate(t *testing.T) {
FILE: pkg/validation/strfmt/default.go
constant HostnamePattern (line 57) | HostnamePattern = `^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62...
constant UUIDPattern (line 59) | UUIDPattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?...
constant UUID3Pattern (line 61) | UUID3Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}...
constant UUID4Pattern (line 63) | UUID4Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a...
constant UUID5Pattern (line 65) | UUID5Pattern = `(?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a...
constant jsonNull (line 67) | jsonNull = "null"
function IsHostname (line 79) | func IsHostname(str string) bool {
function IsUUID (line 101) | func IsUUID(str string) bool {
function IsUUID3 (line 106) | func IsUUID3(str string) bool {
function IsUUID4 (line 111) | func IsUUID4(str string) bool {
function IsUUID5 (line 116) | func IsUUID5(str string) bool {
function IsEmail (line 121) | func IsEmail(str string) bool {
function init (line 126) | func init() {
function isIPv4 (line 210) | func isIPv4(s string) bool {
function isCIDR (line 216) | func isCIDR(s string) bool {
type Base64 (line 224) | type Base64
method MarshalText (line 227) | func (b Base64) MarshalText() ([]byte, error) {
method UnmarshalText (line 236) | func (b *Base64) UnmarshalText(data []byte) error { // validation is p...
method String (line 249) | func (b Base64) String() string {
method MarshalJSON (line 254) | func (b Base64) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 259) | func (b *Base64) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 273) | func (b *Base64) DeepCopyInto(out *Base64) {
method DeepCopy (line 278) | func (b *Base64) DeepCopy() *Base64 {
type URI (line 290) | type URI
method MarshalText (line 293) | func (u URI) MarshalText() ([]byte, error) {
method UnmarshalText (line 298) | func (u *URI) UnmarshalText(data []byte) error { // validation is perf...
method String (line 303) | func (u URI) String() string {
method MarshalJSON (line 308) | func (u URI) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 313) | func (u *URI) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 323) | func (u *URI) DeepCopyInto(out *URI) {
method DeepCopy (line 328) | func (u *URI) DeepCopy() *URI {
type Email (line 340) | type Email
method MarshalText (line 343) | func (e Email) MarshalText() ([]byte, error) {
method UnmarshalText (line 348) | func (e *Email) UnmarshalText(data []byte) error { // validation is pe...
method String (line 353) | func (e Email) String() string {
method MarshalJSON (line 358) | func (e Email) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 363) | func (e *Email) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 373) | func (e *Email) DeepCopyInto(out *Email) {
method DeepCopy (line 378) | func (e *Email) DeepCopy() *Email {
type Hostname (line 390) | type Hostname
method MarshalText (line 393) | func (h Hostname) MarshalText() ([]byte, error) {
method UnmarshalText (line 398) | func (h *Hostname) UnmarshalText(data []byte) error { // validation is...
method String (line 403) | func (h Hostname) String() string {
method MarshalJSON (line 408) | func (h Hostname) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 413) | func (h *Hostname) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 423) | func (h *Hostname) DeepCopyInto(out *Hostname) {
method DeepCopy (line 428) | func (h *Hostname) DeepCopy() *Hostname {
type IPv4 (line 440) | type IPv4
method MarshalText (line 443) | func (u IPv4) MarshalText() ([]byte, error) {
method UnmarshalText (line 448) | func (u *IPv4) UnmarshalText(data []byte) error { // validation is per...
method String (line 453) | func (u IPv4) String() string {
method MarshalJSON (line 458) | func (u IPv4) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 463) | func (u *IPv4) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 473) | func (u *IPv4) DeepCopyInto(out *IPv4) {
method DeepCopy (line 478) | func (u *IPv4) DeepCopy() *IPv4 {
type IPv6 (line 490) | type IPv6
method MarshalText (line 493) | func (u IPv6) MarshalText() ([]byte, error) {
method UnmarshalText (line 498) | func (u *IPv6) UnmarshalText(data []byte) error { // validation is per...
method String (line 503) | func (u IPv6) String() string {
method MarshalJSON (line 508) | func (u IPv6) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 513) | func (u *IPv6) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 523) | func (u *IPv6) DeepCopyInto(out *IPv6) {
method DeepCopy (line 528) | func (u *IPv6) DeepCopy() *IPv6 {
type CIDR (line 540) | type CIDR
method MarshalText (line 543) | func (u CIDR) MarshalText() ([]byte, error) {
method UnmarshalText (line 548) | func (u *CIDR) UnmarshalText(data []byte) error { // validation is per...
method String (line 553) | func (u CIDR) String() string {
method MarshalJSON (line 558) | func (u CIDR) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 563) | func (u *CIDR) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 573) | func (u *CIDR) DeepCopyInto(out *CIDR) {
method DeepCopy (line 578) | func (u *CIDR) DeepCopy() *CIDR {
type MAC (line 590) | type MAC
method MarshalText (line 593) | func (u MAC) MarshalText() ([]byte, error) {
method UnmarshalText (line 598) | func (u *MAC) UnmarshalText(data []byte) error { // validation is perf...
method String (line 603) | func (u MAC) String() string {
method MarshalJSON (line 608) | func (u MAC) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 613) | func (u *MAC) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 623) | func (u *MAC) DeepCopyInto(out *MAC) {
method DeepCopy (line 628) | func (u *MAC) DeepCopy() *MAC {
type UUID (line 640) | type UUID
method MarshalText (line 643) | func (u UUID) MarshalText() ([]byte, error) {
method UnmarshalText (line 648) | func (u *UUID) UnmarshalText(data []byte) error { // validation is per...
method String (line 653) | func (u UUID) String() string {
method MarshalJSON (line 658) | func (u UUID) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 663) | func (u *UUID) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 676) | func (u *UUID) DeepCopyInto(out *UUID) {
method DeepCopy (line 681) | func (u *UUID) DeepCopy() *UUID {
type UUID3 (line 693) | type UUID3
method MarshalText (line 696) | func (u UUID3) MarshalText() ([]byte, error) {
method UnmarshalText (line 701) | func (u *UUID3) UnmarshalText(data []byte) error { // validation is pe...
method String (line 706) | func (u UUID3) String() string {
method MarshalJSON (line 711) | func (u UUID3) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 716) | func (u *UUID3) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 729) | func (u *UUID3) DeepCopyInto(out *UUID3) {
method DeepCopy (line 734) | func (u *UUID3) DeepCopy() *UUID3 {
type UUID4 (line 746) | type UUID4
method MarshalText (line 749) | func (u UUID4) MarshalText() ([]byte, error) {
method UnmarshalText (line 754) | func (u *UUID4) UnmarshalText(data []byte) error { // validation is pe...
method String (line 759) | func (u UUID4) String() string {
method MarshalJSON (line 764) | func (u UUID4) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 769) | func (u *UUID4) UnmarshalJSON(data []byte) error {
method DeepCopyInto (line 782) | func (u
Copy disabled (too large)
Download .json
Condensed preview — 402 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (23,732K chars).
[
{
"path": ".github/dependabot.yml",
"chars": 501,
"preview": "version: 2\nupdates:\n# Disable gomod update\n# See https://github.com/kubernetes/kube-openapi/pull/474?issuecomment-230502"
},
{
"path": ".github/workflows/ci.yml",
"chars": 1374,
"preview": "name: ci-pipeline\non:\n push:\n branches: [ master ]\n pull_request:\n branches: [ master ]\njobs:\n ci:\n strategy"
},
{
"path": ".gitignore",
"chars": 320,
"preview": "# Binaries for programs and plugins\n*.exe\n*.dll\n*.so\n*.dylib\n\n# Test binary, build with `go test -c`\n*.test\n\n# Output of"
},
{
"path": "CONTRIBUTING.md",
"chars": 496,
"preview": "# Contributing\n\nThanks for taking the time to join our community and start contributing!\n\nThe [Contributor Guide](https:"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "OWNERS",
"chars": 147,
"preview": "reviewers:\n- sttts\n- jpbetz\n- jefftree\napprovers:\n- sttts\n- jpbetz\n- jefftree\nemeritus_approvers:\n- mbohlool\n- lavalamp\n"
},
{
"path": "README.md",
"chars": 717,
"preview": "# Kube OpenAPI\n\nThis repo is the home for Kubernetes OpenAPI discovery spec generation. The goal \nis to support a subset"
},
{
"path": "SECURITY.md",
"chars": 1069,
"preview": "# Security Policy\n\n## Security Announcements\n\nJoin the [kubernetes-security-announce] group for security and vulnerabili"
},
{
"path": "SECURITY_CONTACTS",
"chars": 533,
"preview": "# Defined below are the security contacts for this repo.\n#\n# They are the contact point for the Product Security Committ"
},
{
"path": "boilerplate/boilerplate.go.txt",
"chars": 566,
"preview": "/*\nCopyright The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use th"
},
{
"path": "cmd/openapi-gen/args/args.go",
"chars": 4185,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "cmd/openapi-gen/openapi-gen.go",
"chars": 2469,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "cmd/openapi2smd/openapi2smd.go",
"chars": 1490,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "code-of-conduct.md",
"chars": 148,
"preview": "# Kubernetes Community Code of Conduct\n\nPlease refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/co"
},
{
"path": "go.mod",
"chars": 1620,
"preview": "module k8s.io/kube-openapi\n\ngo 1.23.0\n\nrequire (\n\tgithub.com/NYTimes/gziphandler v1.1.1\n\tgithub.com/emicklei/go-restful/"
},
{
"path": "go.sum",
"chars": 8671,
"preview": "github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=\ngithub.com/NYTimes/gziphandler v1."
},
{
"path": "hack/JSON-EXPERIMENTAL-HASH",
"chars": 41,
"preview": "540f014424240312547dcccddf11a8229ca0f463\n"
},
{
"path": "hack/update-json-library.sh",
"chars": 1308,
"preview": "#!/usr/bin/env bash\n# This script can be called via ./hack/update-json-library.sh` to update the\n# go-json-experiment fo"
},
{
"path": "hack/verify-go-directive.sh",
"chars": 1601,
"preview": "#!/usr/bin/env bash\n\n# Copyright 2024 The Kubernetes Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"L"
},
{
"path": "pkg/aggregator/aggregator.go",
"chars": 13598,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/aggregator/aggregator_test.go",
"chars": 55929,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/aggregator/walker.go",
"chars": 4430,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/doc.go",
"chars": 809,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/openapi.go",
"chars": 15443,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/openapi_test.go",
"chars": 17743,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/parameters.go",
"chars": 6987,
"preview": "/*\nCopyright 2023 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/parameters_test.go",
"chars": 8889,
"preview": "/*\nCopyright 2023 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder/util.go",
"chars": 1662,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder3/openapi.go",
"chars": 15057,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder3/openapi_test.go",
"chars": 15898,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder3/util/util.go",
"chars": 1600,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/builder3/util.go",
"chars": 1356,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/cached/cache.go",
"chars": 9334,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/cached/cache_test.go",
"chars": 36327,
"preview": "/*\nCopyright 2023 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/common/common.go",
"chars": 11356,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/common/doc.go",
"chars": 687,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/common/interfaces.go",
"chars": 3086,
"preview": "package common\n\n// RouteContainer is the entrypoint for a service, which may contain multiple\n// routes under a common p"
},
{
"path": "pkg/common/restfuladapter/adapter.go",
"chars": 431,
"preview": "package restfuladapter\n\nimport (\n\t\"github.com/emicklei/go-restful/v3\"\n\t\"k8s.io/kube-openapi/pkg/common\"\n)\n\n// AdaptWebSe"
},
{
"path": "pkg/common/restfuladapter/param_adapter.go",
"chars": 1175,
"preview": "package restfuladapter\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/emicklei/go-restful/v3\"\n\t\"k8s.io/kube-openapi/pkg/common\""
},
{
"path": "pkg/common/restfuladapter/response_error_adapter.go",
"chars": 533,
"preview": "package restfuladapter\n\nimport (\n\t\"github.com/emicklei/go-restful/v3\"\n\t\"k8s.io/kube-openapi/pkg/common\"\n)\n\nvar _ common."
},
{
"path": "pkg/common/restfuladapter/route_adapter.go",
"chars": 1512,
"preview": "package restfuladapter\n\nimport (\n\t\"github.com/emicklei/go-restful/v3\"\n\t\"k8s.io/kube-openapi/pkg/common\"\n)\n\nvar _ common."
},
{
"path": "pkg/common/restfuladapter/webservice_adapter.go",
"chars": 833,
"preview": "package restfuladapter\n\nimport (\n\t\"github.com/emicklei/go-restful/v3\"\n\t\"k8s.io/kube-openapi/pkg/common\"\n)\n\nvar _ common."
},
{
"path": "pkg/generators/README.md",
"chars": 1755,
"preview": "# Generate OpenAPI definitions\n\n- To generate definition for a specific type or package add \"+k8s:openapi-gen=true\" tag "
},
{
"path": "pkg/generators/api_linter.go",
"chars": 6213,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/config.go",
"chars": 4419,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/config_test.go",
"chars": 4982,
"preview": "/*\nCopyright The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use th"
},
{
"path": "pkg/generators/enum.go",
"chars": 5149,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/enum_test.go",
"chars": 6195,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/extension.go",
"chars": 5660,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/extension_test.go",
"chars": 12166,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/markers.go",
"chars": 27673,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/markers_test.go",
"chars": 28273,
"preview": "/*\nCopyright 2023 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/model_names.go",
"chars": 4645,
"preview": "/*\nCopyright 2025 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/openapi.go",
"chars": 35657,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/openapi_test.go",
"chars": 90056,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/OWNERS",
"chars": 44,
"preview": "reviewers:\n- roycaihw\napprovers:\n- roycaihw\n"
},
{
"path": "pkg/generators/rules/doc.go",
"chars": 961,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/idl_tag.go",
"chars": 1324,
"preview": "package rules\n\nimport (\n\t\"k8s.io/gengo/v2\"\n\t\"k8s.io/gengo/v2/types\"\n)\n\nconst ListTypeIDLTag = \"listType\"\n\n// ListTypeMis"
},
{
"path": "pkg/generators/rules/idl_tag_test.go",
"chars": 2673,
"preview": "package rules\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n\n\t\"k8s.io/gengo/v2/types\"\n)\n\nfunc TestListTypeMissing(t *testing.T) {\n\ttcs"
},
{
"path": "pkg/generators/rules/list_type_streaming_tags.go",
"chars": 3645,
"preview": "/*\nCopyright 2025 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/list_type_streaming_tags_test.go",
"chars": 8118,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/names_match.go",
"chars": 5846,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/names_match_test.go",
"chars": 9361,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/omitempty_match_case.go",
"chars": 1557,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/rules/omitempty_match_case_test.go",
"chars": 2202,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/generators/union.go",
"chars": 6379,
"preview": "/*\nCopyright 2016 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/handler/default_pruning.go",
"chars": 5517,
"preview": "/*\nCopyright 2020 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/handler/default_pruning_test.go",
"chars": 4054,
"preview": "/*\nCopyright 2020 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/handler/handler.go",
"chars": 7235,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/handler/handler_test.go",
"chars": 8297,
"preview": "package handler\n\nimport (\n\tjson \"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"os\"\n\t\"reflect\"\n\t"
},
{
"path": "pkg/handler3/handler.go",
"chars": 9413,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/handler3/handler_test.go",
"chars": 17128,
"preview": "/*\n Copyright 2021 The Kubernetes Authors.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you "
},
{
"path": "pkg/idl/doc.go",
"chars": 5037,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/idl/listtype_test.go",
"chars": 1558,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/idl/maptype_test.go",
"chars": 863,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/idl/structtype_test.go",
"chars": 927,
"preview": "/*\nCopyright 2018 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/internal/flags.go",
"chars": 908,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/internal/serialization.go",
"chars": 1914,
"preview": "/*\nCopyright 2023 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/internal/serialization_test.go",
"chars": 2136,
"preview": "/*\n Copyright 2023 The Kubernetes Authors.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may no"
},
{
"path": "pkg/internal/third_party/go-json-experiment/README.md",
"chars": 216,
"preview": "Forked from: https://github.com/go-json-experiment/json\nCommit Hash: 540f014424240312547dcccddf11a8229ca0f463\n\nThis inte"
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/AUTHORS",
"chars": 174,
"preview": "# This source code refers to The Go Authors for copyright purposes.\n# The master list of authors is in the main Go distr"
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/CONTRIBUTORS",
"chars": 171,
"preview": "# This source code was written by the Go contributors.\n# The master list of contributors is in the main Go distribution,"
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/LICENSE",
"chars": 1479,
"preview": "Copyright (c) 2020 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or with"
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/README.md",
"chars": 19986,
"preview": "# JSON Serialization (v2)\n\n[](https"
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal.go",
"chars": 23195,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_any.go",
"chars": 6043,
"preview": "// Copyright 2022 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_default.go",
"chars": 45971,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_funcs.go",
"chars": 14256,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_inlined.go",
"chars": 6605,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_methods.go",
"chars": 9226,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_test.go",
"chars": 271310,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/arshal_time.go",
"chars": 8227,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/bench_test.go",
"chars": 20449,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/coder_test.go",
"chars": 21557,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/decode.go",
"chars": 52019,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/decode_test.go",
"chars": 47837,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/diff_test.go",
"chars": 45247,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/doc.go",
"chars": 10077,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/encode.go",
"chars": 37502,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/encode_test.go",
"chars": 32567,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/errors.go",
"chars": 4627,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/errors_test.go",
"chars": 6910,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/example_orderedobject_test.go",
"chars": 3224,
"preview": "// Copyright 2022 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/example_test.go",
"chars": 27644,
"preview": "// Copyright 2022 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/fields.go",
"chars": 19153,
"preview": "// Copyright 2021 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/fields_test.go",
"chars": 21431,
"preview": "// Copyright 2021 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/fold.go",
"chars": 1457,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/fold_test.go",
"chars": 3827,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/fuzz_test.go",
"chars": 7833,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/inline_test.go",
"chars": 3130,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/intern.go",
"chars": 2535,
"preview": "// Copyright 2022 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/intern_test.go",
"chars": 3648,
"preview": "// Copyright 2022 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/pools.go",
"chars": 6033,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/state.go",
"chars": 23978,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/state_test.go",
"chars": 10002,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/testdata_test.go",
"chars": 25826,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/token.go",
"chars": 14652,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/token_test.go",
"chars": 6615,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/value.go",
"chars": 12596,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/go-json-experiment/json/value_test.go",
"chars": 8256,
"preview": "// Copyright 2020 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "pkg/internal/third_party/govalidator/LICENSE",
"chars": 1080,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Alex Saskevich\n\nPermission is hereby granted, free of charge, to any person ob"
},
{
"path": "pkg/internal/third_party/govalidator/patterns.go",
"chars": 1173,
"preview": "package govalidator\n\nimport \"regexp\"\n\n// Basic regular expressions for validating strings\nconst (\n\tCreditCard string = \""
},
{
"path": "pkg/internal/third_party/govalidator/validator.go",
"chars": 4268,
"preview": "// Package govalidator is package of validators and sanitizers for strings, structs and collections.\npackage govalidator"
},
{
"path": "pkg/internal/third_party/govalidator/validator_test.go",
"chars": 8948,
"preview": "package govalidator\n\nimport (\n\t\"testing\"\n)\n\nfunc TestIsRequestURI(t *testing.T) {\n\tt.Parallel()\n\n\tvar tests = []struct {"
},
{
"path": "pkg/openapiconv/convert.go",
"chars": 9822,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/openapiconv/convert_test.go",
"chars": 2009,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/README.md",
"chars": 138,
"preview": "Please do not edit these test files by hand. They were generated from running the OpenAPI v2 and v3 builders on select K"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v2_api.v1.json",
"chars": 1035923,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/api/v1/\":{\"get\":{\"description\":\"get availa"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v2_apiextensions.k8s.io.v1.json",
"chars": 112410,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/apis/apiextensions.k8s.io/v1/\":{\"get\":{\"de"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v2_batch.v1.json",
"chars": 298018,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/apis/batch/v1/\":{\"get\":{\"description\":\"get"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v3_api.v1.json",
"chars": 1124182,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/api/v1/\":{\"get\":{\"tags\":[\"core_v1\"],\"des"
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v3_apiextensions.k8s.io.v1.json",
"chars": 119864,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/apis/apiextensions.k8s.io/v1/\":{\"get\":{\""
},
{
"path": "pkg/openapiconv/testdata_generated_from_k8s/v3_batch.v1.json",
"chars": 312995,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.24.0\"},\"paths\":{\"/apis/batch/v1/\":{\"get\":{\"tags\":[\"batch_v"
},
{
"path": "pkg/schemaconv/openapi.go",
"chars": 7424,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemaconv/openapi_test.go",
"chars": 11980,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemaconv/proto_models.go",
"chars": 4637,
"preview": "/*\nCopyright 2022 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemaconv/smd.go",
"chars": 8928,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemaconv/smd_test.go",
"chars": 4805,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemaconv/testdata/atomic-types.json",
"chars": 595,
"preview": "{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Atomic Types\",\n \"version\": \"v1.0.0\"\n },\n \"paths\": {\n },\n \"definit"
},
{
"path": "pkg/schemaconv/testdata/atomic-types.yaml",
"chars": 742,
"preview": "types:\n- name: io.k8s.testcase.AtomicMapField\n map:\n fields:\n - name: atomicField\n type:\n map:\n "
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json",
"chars": 130296,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/accesscontextmanager.cnrm.cloud.googl"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/container_v1beta1_containercluster.json",
"chars": 142911,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/container.cnrm.cloud.google.com/v1bet"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/dataproc_v1beta1_dataprocworkflowtemplate.json",
"chars": 163421,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/dataproc.cnrm.cloud.google.com/v1beta"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/dlp_v1beta1_dlpdeidentifytemplate.json",
"chars": 193738,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/dlp.cnrm.cloud.google.com/v1beta1/dlp"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/monitoring_v1beta1_monitoringalertpolicy.json",
"chars": 123421,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/monitoring.cnrm.cloud.google.com/v1be"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/monitoring_v1beta1_monitoringdashboard.json",
"chars": 304068,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/monitoring.cnrm.cloud.google.com/v1be"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/privateca_v1beta1_privatecacertificate.json",
"chars": 122498,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/privateca.cnrm.cloud.google.com/v1bet"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/privateca_v1beta1_privatecacertificateauthority.json",
"chars": 125408,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/privateca.cnrm.cloud.google.com/v1bet"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/storagetransfer_v1beta1_storagetransferjob.json",
"chars": 112134,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/storagetransfer.cnrm.cloud.google.com"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv2/vpcaccess_v1beta1_vpcaccessconnector.json",
"chars": 103641,
"preview": "{\"swagger\":\"2.0\",\"info\":{\"title\":\"Kubernetes\",\"version\":\"v1.27.0\"},\"paths\":{\"/apis/vpcaccess.cnrm.cloud.google.com/v1bet"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/accesscontextmanager_v1beta1_accesscontextmanagerserviceperimeter.json",
"chars": 51542,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/container_v1beta1_containercluster.json",
"chars": 65806,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/dataproc_v1beta1_dataprocworkflowtemplate.json",
"chars": 85771,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/dlp_v1beta1_dlpdeidentifytemplate.json",
"chars": 121439,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/monitoring_v1beta1_monitoringalertpolicy.json",
"chars": 43394,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/monitoring_v1beta1_monitoringdashboard.json",
"chars": 226318,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/privateca_v1beta1_privatecacertificate.json",
"chars": 43388,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/privateca_v1beta1_privatecacertificateauthority.json",
"chars": 45895,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/storagetransfer_v1beta1_storagetransferjob.json",
"chars": 33095,
"preview": "{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Kubernetes CRD Swagger\",\"version\":\"v0.1.0\"},\"components\":{\"schemas\":{\"com.google.clo"
},
{
"path": "pkg/schemaconv/testdata/crds/openapiv3/vpcaccess_v1beta1_vpcaccessconnector.json",
"chars": 32267,
"preview": "{\n \"openapi\": \"3.0.0\",\n \"info\": { \"title\": \"Kubernetes CRD Swagger\", \"version\": \"v0.1.0\" },\n \"components\": {\n \"sch"
},
{
"path": "pkg/schemaconv/testdata/defaults.json",
"chars": 599,
"preview": "{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Atomic Types\",\n \"version\": \"v1.0.0\"\n },\n \"paths\": {"
},
{
"path": "pkg/schemaconv/testdata/defaults.yaml",
"chars": 674,
"preview": "types:\n- name: List\n list:\n elementType:\n map:\n fields:\n - name: foo\n type:\n "
},
{
"path": "pkg/schemaconv/testdata/field-level-annotation.json",
"chars": 4486,
"preview": "{\n \"definitions\": {\n \"io.k8s.api.core.v1.ObjectReference\": {\n \"description\": \"ObjectReference conta"
},
{
"path": "pkg/schemaconv/testdata/new-schema.yaml",
"chars": 216602,
"preview": "types:\n- name: io.k8s.api.admissionregistration.v1.MutatingWebhook\n map:\n fields:\n - name: admissionReviewVersion"
},
{
"path": "pkg/schemaconv/testdata/preserve-unknown.json",
"chars": 840,
"preview": "{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Atomic Types\",\n \"version\": \"v1.0.0\"\n },\n \"paths\": {\n },\n \"definit"
},
{
"path": "pkg/schemaconv/testdata/preserve-unknown.yaml",
"chars": 1496,
"preview": "types:\n- name: io.k8s.testcase.Empty\n map:\n elementType:\n scalar: untyped\n list:\n elementType:\n "
},
{
"path": "pkg/schemaconv/testdata/swagger.json",
"chars": 4038284,
"preview": "{\n \"swagger\": \"2.0\",\n \"info\": { \"title\": \"Kubernetes\", \"version\": \"v1.27.0\" },\n \"paths\": {\n \"/.well-known/openid-c"
},
{
"path": "pkg/schemamutation/walker.go",
"chars": 11949,
"preview": "/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/schemamutation/walker_test.go",
"chars": 12241,
"preview": "/*\nCopyright 2019 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/benchmark_serialization_test.go",
"chars": 6994,
"preview": "package spec3\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/google/go-cmp/cmp\"\n\t\"k8s"
},
{
"path": "pkg/spec3/component.go",
"chars": 2379,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/component_test.go",
"chars": 18112,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/encoding.go",
"chars": 3420,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/encoding_test.go",
"chars": 2476,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/example.go",
"chars": 3132,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/example_test.go",
"chars": 2083,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/external_documentation.go",
"chars": 2709,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/external_documentation_test.go",
"chars": 2201,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/fuzz.go",
"chars": 6303,
"preview": "package spec3\n\nimport (\n\t\"math/rand\"\n\t\"strings\"\n\n\t\"sigs.k8s.io/randfill\"\n\n\t\"k8s.io/kube-openapi/pkg/validation/spec\"\n)\n\n"
},
{
"path": "pkg/spec3/header.go",
"chars": 5179,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/header_test.go",
"chars": 2256,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/media_type.go",
"chars": 3733,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/media_type_test.go",
"chars": 2117,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/operation.go",
"chars": 5015,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/operation_test.go",
"chars": 4310,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/parameter.go",
"chars": 5678,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/parameter_test.go",
"chars": 2924,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/path.go",
"chars": 7001,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/path_test.go",
"chars": 4506,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/request_body.go",
"chars": 3770,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/request_body_test.go",
"chars": 2467,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/response.go",
"chars": 10599,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/response_test.go",
"chars": 3381,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/security_scheme.go",
"chars": 4692,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/security_scheme_test.go",
"chars": 3438,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/server.go",
"chars": 4637,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/server_test.go",
"chars": 2111,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/spec.go",
"chars": 2913,
"preview": "/*\nCopyright 2021 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not u"
},
{
"path": "pkg/spec3/testdata/appsv1spec.json",
"chars": 757197,
"preview": "{\n \"components\": {\n \"schemas\": {\n \"io.k8s.api.apps.v1.ControllerRevision\": {\n \"description\": \"Controller"
},
{
"path": "pkg/spec3/testdata/authorizationv1spec.json",
"chars": 67110,
"preview": "{\n \"components\": {\n \"schemas\": {\n \"io.k8s.api.authorization.v1.LocalSubjectAccessReview\": {\n \"descriptio"
}
]
// ... and 202 more files (download for full content)
About this extraction
This page contains the full source code of the kubernetes/kube-openapi GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 402 files (21.2 MB), approximately 5.6M tokens, and a symbol index with 2825 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.