Skip to content

Commit

Permalink
fix: server openapi model generation (#2230)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Mar 21, 2023
1 parent 9718e55 commit 98240bc
Show file tree
Hide file tree
Showing 14 changed files with 1,095 additions and 1 deletion.
1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -80,7 +80,6 @@ server/openapi: $(OPENAPI_SRC_FILES)
$(OPENAPI_GENERATOR_CLI) generate \
-i api/openapi.yaml \
-g go-server \
--global-property apis="api" \
-o $(BASE)/tmp \
--generate-alias-as-model
cp $(BASE)/tmp/go/*.go $(BASE)/$(OPENAPI_TARGET_DIR)
Expand Down
37 changes: 37 additions & 0 deletions server/openapi/api.go
Expand Up @@ -66,6 +66,24 @@ type ApiApiRouter interface {
UpsertDefinition(http.ResponseWriter, *http.Request)
}

// ResourceApiApiRouter defines the required methods for binding the api requests to a responses for the ResourceApiApi
// The ResourceApiApiRouter implementation should parse necessary information from the http request,
// pass the data to a ResourceApiApiServicer to perform the required actions, then write the service results to the http response.
type ResourceApiApiRouter interface {
CreateDemo(http.ResponseWriter, *http.Request)
CreatePollingProfile(http.ResponseWriter, *http.Request)
DeleteDemo(http.ResponseWriter, *http.Request)
DeletePollingProfile(http.ResponseWriter, *http.Request)
GetConfiguration(http.ResponseWriter, *http.Request)
GetDemo(http.ResponseWriter, *http.Request)
GetPollingProfile(http.ResponseWriter, *http.Request)
ListDemos(http.ResponseWriter, *http.Request)
ListPollingProfiles(http.ResponseWriter, *http.Request)
UpdateConfiguration(http.ResponseWriter, *http.Request)
UpdateDemo(http.ResponseWriter, *http.Request)
UpdatePollingProfile(http.ResponseWriter, *http.Request)
}

// ApiApiServicer defines the api actions for the ApiApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can be ignored with the .openapi-generator-ignore file
Expand Down Expand Up @@ -118,3 +136,22 @@ type ApiApiServicer interface {
UpdateTransaction(context.Context, string, Transaction) (ImplResponse, error)
UpsertDefinition(context.Context, TextDefinition) (ImplResponse, error)
}

// ResourceApiApiServicer defines the api actions for the ResourceApiApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type ResourceApiApiServicer interface {
CreateDemo(context.Context, Demo) (ImplResponse, error)
CreatePollingProfile(context.Context, PollingProfile) (ImplResponse, error)
DeleteDemo(context.Context, string) (ImplResponse, error)
DeletePollingProfile(context.Context, string) (ImplResponse, error)
GetConfiguration(context.Context, string) (ImplResponse, error)
GetDemo(context.Context, string) (ImplResponse, error)
GetPollingProfile(context.Context, string) (ImplResponse, error)
ListDemos(context.Context, int32, int32, string, string) (ImplResponse, error)
ListPollingProfiles(context.Context, int32, int32, string, string) (ImplResponse, error)
UpdateConfiguration(context.Context, string, ConfigurationResource) (ImplResponse, error)
UpdateDemo(context.Context, string, Demo) (ImplResponse, error)
UpdatePollingProfile(context.Context, string, PollingProfile) (ImplResponse, error)
}

0 comments on commit 98240bc

Please sign in to comment.