Skip to content

Commit

Permalink
Drop application/yaml content type (sigstore#933)
Browse files Browse the repository at this point in the history
* Drop application/yaml content type

This is a breaking change for any clients that are currently requesting
application/yaml.

This is the simplest fix to sigstore#593, as openapi randomly switches between
json and yaml responses when no content type is provided.

Fixes sigstore#593

Signed-off-by: Hayden Blauzvern <[email protected]>

* remove default-consumes from Makefile

Signed-off-by: Hayden Blauzvern <[email protected]>

* Fix comment generation

Signed-off-by: Hayden Blauzvern <[email protected]>
  • Loading branch information
haydentherapper authored and bobcallaway committed Aug 3, 2022
1 parent ebf0a56 commit d3fa7da
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SERVER_LDFLAGS=$(REKOR_LDFLAGS)

Makefile.swagger: $(SWAGGER) $(OPENAPIDEPS)
$(SWAGGER) validate openapi.yaml
$(SWAGGER) generate client -f openapi.yaml -q -r COPYRIGHT.txt -t pkg/generated --default-consumes application/json\;q=1 --additional-initialism=TUF
$(SWAGGER) generate client -f openapi.yaml -q -r COPYRIGHT.txt -t pkg/generated --additional-initialism=TUF
$(SWAGGER) generate server -f openapi.yaml -q -r COPYRIGHT.txt -t pkg/generated --exclude-main -A rekor_server --flag-strategy=pflag --default-produces application/json --additional-initialism=TUF
@echo "# This file is generated after swagger runs as part of the build; do not edit!" > Makefile.swagger
@echo "SWAGGER_GEN=`find pkg/generated/client pkg/generated/models/ pkg/generated/restapi/ -iname '*.go' | grep -v 'configure_rekor_server' | sort -d | tr '\n' ' ' | sed 's/ $$//'`" >> Makefile.swagger;
Expand Down
4 changes: 1 addition & 3 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ schemes:

consumes:
- application/json
- application/yaml
produces:
- application/json;q=1
- application/yaml
- application/json

paths:
/api/v1/version:
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/rekor_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func GetRekorClient(rekorServerURL string, opts ...Option) (*client.Rekor, error
o := makeOptions(opts...)

rt := httptransport.New(url.Host, client.DefaultBasePath, []string{url.Scheme})
rt.Consumers["application/yaml"] = YamlConsumer()
rt.Consumers["application/json"] = runtime.JSONConsumer()
rt.Consumers["application/x-pem-file"] = runtime.TextConsumer()
rt.Consumers["application/pem-certificate-chain"] = runtime.TextConsumer()
rt.Producers["application/yaml"] = YamlProducer()
rt.Producers["application/json"] = runtime.JSONProducer()
rt.Producers["application/timestamp-query"] = runtime.ByteStreamProducer()
rt.Consumers["application/timestamp-reply"] = runtime.ByteStreamConsumer()

Expand Down
46 changes: 0 additions & 46 deletions pkg/client/yaml.go

This file was deleted.

16 changes: 8 additions & 8 deletions pkg/generated/client/entries/entries_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/generated/client/index/index_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/generated/client/pubkey/pubkey_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/generated/client/server/server_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/generated/client/tlog/tlog_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions pkg/generated/restapi/configure_rekor_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/spf13/viper"

pkgapi "github.com/sigstore/rekor/pkg/api"
"github.com/sigstore/rekor/pkg/client"
"github.com/sigstore/rekor/pkg/generated/restapi/operations"
"github.com/sigstore/rekor/pkg/generated/restapi/operations/entries"
"github.com/sigstore/rekor/pkg/generated/restapi/operations/index"
Expand Down Expand Up @@ -71,9 +70,6 @@ func configureAPI(api *operations.RekorServerAPI) http.Handler {
api.JSONConsumer = runtime.JSONConsumer()
api.JSONProducer = runtime.JSONProducer()

api.YamlConsumer = client.YamlConsumer()
api.YamlProducer = client.YamlProducer()

api.ApplicationXPemFileProducer = runtime.TextProducer()

api.EntriesCreateLogEntryHandler = entries.CreateLogEntryHandlerFunc(pkgapi.CreateLogEntryHandler)
Expand Down
2 changes: 0 additions & 2 deletions pkg/generated/restapi/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions pkg/generated/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions pkg/generated/restapi/operations/rekor_server_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/sharding/ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type LogRanges struct {
type Ranges []LogRange

type LogRange struct {
TreeID int64 `yaml:"treeID"`
TreeLength int64 `yaml:"treeLength"`
EncodedPublicKey string `yaml:"encodedPublicKey"`
TreeID int64 `json:"treeID"`
TreeLength int64 `json:"treeLength"`
EncodedPublicKey string `json:"encodedPublicKey"`
decodedPublicKey string
}

Expand Down

0 comments on commit d3fa7da

Please sign in to comment.