Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
adds v1 openapispec
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftdiaries committed Jun 20, 2019
1 parent bd1cb7d commit c7f19d4
Show file tree
Hide file tree
Showing 4 changed files with 6,594 additions and 7 deletions.
2 changes: 1 addition & 1 deletion generate-openapi-swagger.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to Generate an OpenAPI Spec for PyTorch Operator

From the root of the repo,
`go run hack/gen-openapi-spec/main.go v0.6 > pkg/apis/pytorch/v1beta2/swagger.json`
`go run hack/gen-openapi-spec/main.go v0.6 > pkg/apis/pytorch/v1/swagger.json`

## TODO

Expand Down
10 changes: 5 additions & 5 deletions hack/gen-openapi-spec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"strings"

"github.com/go-openapi/spec"
pytorchjobspec "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1beta2"
pytorchjobspec "github.com/kubeflow/pytorch-operator/pkg/apis/pytorch/v1"
"k8s.io/kube-openapi/pkg/common"
)

Expand All @@ -51,7 +51,7 @@ func main() {
Paths: &spec.Paths{Paths: map[string]spec.PathItem{}},
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "TFOperator",
Title: "PyTorchOperator",
Version: version,
},
},
Expand All @@ -66,11 +66,11 @@ func main() {

// swaggify converts the github package
// e.g.:
// github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1beta2.TFJob
// github.com/kubeflow/tf-operator/pkg/apis/pytorch/v1.TFJob
// to:
// kf.tensorflow.v1beta2.TFJob
// kf.pytorch.v1.TFJob
func swaggify(name string) string {
name = strings.Replace(name, "github.com/kubeflow/tf-operator/pkg/apis/", "kf", -1)
name = strings.Replace(name, "github.com/kubeflow/pytorch-operator/pkg/apis/", "kf", -1)
parts := strings.Split(name, "/")
hostParts := strings.Split(parts[0], ".")
// reverses something like k8s.io to io.k8s
Expand Down
Loading

0 comments on commit c7f19d4

Please sign in to comment.