Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OpenAPI v3 #247

Merged
merged 1 commit into from
Nov 12, 2021
Merged

Conversation

Jefftree
Copy link
Member

@Jefftree Jefftree commented Sep 16, 2021

Most of work around the spec was from https://github.com/p0lyn0mial/kube-openapi/tree/spec3/pkg/spec3.

This PR provides the structs for OpenAPI v3, the builder3 package for building OpenAPI v3, and handler3 for serving OpenAPI v3 separated by group/version.

See kubernetes/kubernetes#105945 for k/k integration

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 16, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2021
@Jefftree Jefftree force-pushed the openapiv3 branch 6 times, most recently from 4cf9bc2 to 2fc535a Compare October 14, 2021 17:37
@Jefftree Jefftree changed the title [WIP] Support for OpenAPI v3 Support for OpenAPI v3 Oct 21, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2021
@Jefftree Jefftree marked this pull request as ready for review October 26, 2021 19:15
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 26, 2021
Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

pkg/handler3/handler.go Show resolved Hide resolved
pkg/handler3/handler.go Show resolved Hide resolved
pkg/handler3/handler.go Outdated Show resolved Hide resolved
pkg/handler3/handler.go Outdated Show resolved Hide resolved
pkg/handler3/handler.go Outdated Show resolved Hide resolved
pkg/spec3/header.go Outdated Show resolved Hide resolved
pkg/spec3/security_scheme_test.go Show resolved Hide resolved
pkg/spec3/spec.go Outdated Show resolved Hide resolved
test/integration/builder3/main.go Outdated Show resolved Hide resolved
pkg/builder3/openapi.go Show resolved Hide resolved
}

// Aggregating common parameters make API spec (and generated clients) simpler
inPathCommonParamsMap, err := o.findCommonParameters(routes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to understand how this aggregator works as an aggregator? this finds the common parameters and copy the spec. right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry I missed this comment earlier. Yes, it finds all parameters in the route's different operations and collects them together (and their spec) to publish.

pkg/builder3/openapi.go Show resolved Hide resolved
test/integration/integration_suite_test.go Show resolved Hide resolved
@Jefftree
Copy link
Member Author

Jefftree commented Nov 2, 2021

/cc @p0lyn0mial @sttts

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2021
@p0lyn0mial
Copy link

Would it make sense to generate a v3 spec for k/k repo and use a validator to validate the generated spec?
I think last time I did https://github.com/p0lyn0mial/kube-oasv3-poc

@Jefftree
Copy link
Member Author

Jefftree commented Nov 8, 2021

@p0lyn0mial I've been using the kin-openapi repo to validate the OpenAPI v3 in the integration tests in kube-openapi.

The PR for k/k kubernetes/kubernetes#105945 also generates the static swagger.json equivalent for all v3 group/versions and I've manually validated a couple of the generated specs. Is there a specific validation tool you'd like to see integrated?

@Jefftree
Copy link
Member Author

Jefftree commented Nov 8, 2021

@p0lyn0mial I've ran your suggested script on the set of files generated in the k/k PR per group.

for f in api/openapi-spec/v3/api*; do pajv validate -s ~/tmp/schema.json -d "$f"; done

and all the group/version paths passed the validation. (https://pastebin.com/6TRfebs5)

@austince austince mentioned this pull request Nov 8, 2021
@Jefftree Jefftree mentioned this pull request Nov 8, 2021
13 tasks
@p0lyn0mial
Copy link

@p0lyn0mial I've been using the kin-openapi repo to validate the OpenAPI v3 in the integration tests in kube-openapi.

sgtm, we should validate a spec generated directly from this repo

The PR for k/k kubernetes/kubernetes#105945 also generates the static swagger.json equivalent for all v3 group/versions and I've manually validated a couple of the generated specs. Is there a specific validation tool you'd like to see integrated?

nothing specific, I just wanted to make sure the spec generated from k/k repo is a valid OAS v3 spec.

pkg/builder3/openapi.go Outdated Show resolved Hide resolved
pkg/builder3/openapi.go Outdated Show resolved Hide resolved
pkg/builder3/openapi.go Show resolved Hide resolved
pkg/builder3/openapi.go Outdated Show resolved Hide resolved
pkg/handler3/handler.go Outdated Show resolved Hide resolved
pkg/handler3/handler.go Show resolved Hide resolved
@Jefftree Jefftree force-pushed the openapiv3 branch 5 times, most recently from d22ae4f to 619a821 Compare November 10, 2021 23:53
@apelisse
Copy link
Member

Looks good to me, feel free to tag @sttts, thanks!

@Jefftree Jefftree force-pushed the openapiv3 branch 2 times, most recently from 577b8dc to 0e745f0 Compare November 12, 2021 01:05
@Jefftree
Copy link
Member Author

Jefftree commented Nov 12, 2021

/retest (the robot doesn't work here?)
No changes, force pushed to clean up the formatting

@apelisse
Copy link
Member

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, Jefftree

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 12, 2021
@k8s-ci-robot k8s-ci-robot merged commit 9cd6b59 into kubernetes:master Nov 12, 2021
@Jefftree Jefftree deleted the openapiv3 branch March 21, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants