Skip to content

Commit

Permalink
feat: add search endpoint - add OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Dec 20, 2024
1 parent 8be5610 commit d6d2f01
Show file tree
Hide file tree
Showing 3 changed files with 684 additions and 6 deletions.
9 changes: 9 additions & 0 deletions config/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ func (c *Config) AllCollections() GeoSpatialCollections {
return c.Collections
}

func (g GeoSpatialCollections) SupportsSearch() bool {
for _, collection := range g {
if collection.Search != nil {
return true
}
}
return false
}

// Unique lists all unique GeoSpatialCollections (no duplicate IDs).
// Don't use in hot path (creates a map on every invocation).
func (g GeoSpatialCollections) Unique() []GeoSpatialCollection {
Expand Down
16 changes: 10 additions & 6 deletions internal/engine/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import (
)

const (
specPath = templatesDir + "openapi/"
preamble = specPath + "preamble.go.json"
problems = specPath + "problems.go.json"
commonCollections = specPath + "common-collections.go.json"
commonSpec = specPath + "common.go.json"
HTMLRegex = `<[/]?([a-zA-Z]+).*?>`
specPath = templatesDir + "openapi/"
preamble = specPath + "preamble.go.json"
problems = specPath + "problems.go.json"
commonCollections = specPath + "common-collections.go.json"
commonSpec = specPath + "common.go.json"
featuresSearchSpec = specPath + "features-search.go.json"
HTMLRegex = `<[/]?([a-zA-Z]+).*?>`
)

type OpenAPI struct {
Expand All @@ -51,6 +52,9 @@ func newOpenAPI(config *gomagpieconfig.Config) *OpenAPI {
if config.AllCollections() != nil {
defaultOpenAPIFiles = append(defaultOpenAPIFiles, commonCollections)
}
if config.Collections.SupportsSearch() {
defaultOpenAPIFiles = append(defaultOpenAPIFiles, featuresSearchSpec)
}

// add preamble first
openAPIFiles := []string{preamble}
Expand Down
Loading

0 comments on commit d6d2f01

Please sign in to comment.