Skip to content

Commit

Permalink
refactor: update OpenAPI spec endpoint path
Browse files Browse the repository at this point in the history
Change OpenAPI v3 spec endpoint from /api/wfx/v1/openapiv3.json to
/api/wfx/v1/openapi.json. This change aligns with the convention of
using openapi.json as the standard name to serve the OpenAPI spec.

Signed-off-by: Michael Adler <[email protected]>
  • Loading branch information
michaeladler authored and stormc committed Feb 7, 2025
1 parent a9a70d3 commit fd29b40
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `wfxctl workflow query` now accepts a `sort` param
- Added (existing but undocumented) `/health` and `/version` endpoint to OpenAPI spec
- OpenAPI v3 spec is served at `/api/wfx/v1/openapiv3.json`
- OpenAPI v3 spec is served at `/api/wfx/v1/openapi.json`

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion cmd/wfx/cmd/root/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestAPI(t *testing.T) {
httpClient := new(http.Client)
var spec openapi3.T
for i := 0; i < 100; i++ {
resp, err := httpClient.Get("http://localhost:8080/api/wfx/v1/openapiv3.json")
resp, err := httpClient.Get("http://localhost:8080/api/wfx/v1/openapi.json")
if err != nil {
time.Sleep(time.Millisecond * 10)
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/wfx/cmd/root/server_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestNewServerCollection(t *testing.T) {
func TestOpenAPIJSON(t *testing.T) {
mux := createMux(new(config.AppConfig), nil)
rec := httptest.NewRecorder()
mux.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/api/wfx/v1/openapiv3.json", nil))
mux.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/api/wfx/v1/openapi.json", nil))
result := rec.Result()
assert.Equal(t, http.StatusOK, result.StatusCode)
}
Expand All @@ -45,7 +45,7 @@ func TestTopLevelNotFound(t *testing.T) {
result := rec.Result()
assert.Equal(t, http.StatusNotFound, result.StatusCode)
b, _ := io.ReadAll(result.Body)
assert.Equal(t, "The requested resource could not be found.\n\nHint: Check /api/wfx/v1/openapiv3.json to see available endpoints.\n", string(b))
assert.Equal(t, "The requested resource could not be found.\n\nHint: Check /api/wfx/v1/openapi.json to see available endpoints.\n", string(b))
}

func TestDownloadRedirect(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ wfx provides two RESTful APIs to interact with it: the northbound operator/manag
The northbound API is used to create jobs and execute server-side state transitions, whereas the southbound
API is used for client-side transitions.

The complete [wfx API specification](../spec/wfx.openapiv3.yml) is accessible at runtime via the `/api/wfx/v1/openapiv3.json` endpoint.
The complete [wfx API specification](../spec/wfx.openapiv3.yml) is accessible at runtime via the `/api/wfx/v1/openapi.json` endpoint.
Clients may inspect this specification at run-time so to obey the various limits imposed, e.g, for parameter value ranges and array lengths.

### Job Events
Expand Down
2 changes: 1 addition & 1 deletion spec/openapiv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func init() {
servers := yamlObj["servers"].([]any)
servers2 := servers[0].(map[string]any)
basePath := servers2["url"]
specEndpoint := fmt.Sprintf("%s/openapiv3.json", basePath)
specEndpoint := fmt.Sprintf("%s/openapi.json", basePath)

jsonData, err := json.Marshal(yamlObj)
if err != nil {
Expand Down

0 comments on commit fd29b40

Please sign in to comment.