Skip to content

Commit f6e225d

Browse files
committed
feat: Expose ListBaselineStatusCount in OpenAPI spec
This PR updates the OpenAPI documentation to reflect the new /v1/stats/baseline_status/low_date_feature_counts endpoint. This endpoint will return a paginated list of baseline status metrics, providing the count of features that have reached low baseline over time. Next Steps: - Implement the corresponding HTTP handler function to handle requests to this endpoint. - Connect the handler function to the ListBaselineStatusCount Spanner logic implemented in the previous PR. - Add appropriate error handling and logging to the handler. This PR lays the groundwork for exposing the baseline status count functionality through the API.
1 parent 89fe016 commit f6e225d

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package httpserver
16+
17+
import (
18+
"context"
19+
"net/http"
20+
21+
"github.com/GoogleChrome/webstatus.dev/lib/gen/openapi/backend"
22+
)
23+
24+
// ListAggregatedBaselineStatusCounts implements backend.StrictServerInterface.
25+
// nolint: revive, ireturn // Name generated from openapi
26+
func (s *Server) ListAggregatedBaselineStatusCounts(
27+
ctx context.Context, request backend.ListAggregatedBaselineStatusCountsRequestObject) (
28+
backend.ListAggregatedBaselineStatusCountsResponseObject, error) {
29+
return backend.ListAggregatedBaselineStatusCounts400JSONResponse{
30+
Code: http.StatusBadRequest,
31+
Message: "TODO",
32+
}, nil
33+
}

backend/pkg/httpserver/server_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,16 @@ type mockServerInterface struct {
469469
callCount int
470470
}
471471

472+
// ListAggregatedBaselineStatusCounts implements backend.StrictServerInterface.
473+
// nolint: ireturn // WONTFIX - generated method signature
474+
func (m *mockServerInterface) ListAggregatedBaselineStatusCounts(
475+
ctx context.Context, _ backend.ListAggregatedBaselineStatusCountsRequestObject) (
476+
backend.ListAggregatedBaselineStatusCountsResponseObject, error) {
477+
assertUserInCtx(ctx, m.t, m.expectedUserInCtx)
478+
m.callCount++
479+
panic("unimplemented")
480+
}
481+
472482
// CreateSavedSearch implements backend.StrictServerInterface.
473483
// nolint: ireturn // WONTFIX - generated method signature
474484
func (m *mockServerInterface) CreateSavedSearch(ctx context.Context, _ backend.CreateSavedSearchRequestObject) (

openapi/backend/openapi.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,48 @@ paths:
460460
application/json:
461461
schema:
462462
$ref: '#/components/schemas/BasicErrorModel'
463+
/v1/stats/baseline_status/low_date_feature_counts:
464+
get:
465+
summary: >
466+
Returns the count of features supported that have reached baseline
467+
according to the specified date type (currently only low_date).
468+
operationId: listAggregatedBaselineStatusCounts
469+
parameters:
470+
- $ref: '#/components/parameters/startAtParam'
471+
- $ref: '#/components/parameters/endAtParam'
472+
- $ref: '#/components/parameters/paginationTokenParam'
473+
- $ref: '#/components/parameters/paginationSizeParam'
474+
responses:
475+
'200':
476+
description: OK
477+
content:
478+
application/json:
479+
schema:
480+
$ref: '#/components/schemas/BaselineStatusMetricsPage'
481+
'400':
482+
description: Bad Input
483+
content:
484+
application/json:
485+
schema:
486+
$ref: '#/components/schemas/BasicErrorModel'
487+
'404':
488+
description: Not Found
489+
content:
490+
application/json:
491+
schema:
492+
$ref: '#/components/schemas/BasicErrorModel'
493+
'429':
494+
description: Rate Limit
495+
content:
496+
application/json:
497+
schema:
498+
$ref: '#/components/schemas/BasicErrorModel'
499+
'500':
500+
description: Internal Service Error
501+
content:
502+
application/json:
503+
schema:
504+
$ref: '#/components/schemas/BasicErrorModel'
463505
/v1/users/me/saved-searches:
464506
get:
465507
summary: List user saved searches
@@ -903,6 +945,31 @@ components:
903945
$ref: '#/components/schemas/BrowserReleaseFeatureMetric'
904946
required:
905947
- data
948+
BaselineStatusMetric:
949+
type: object
950+
properties:
951+
timestamp:
952+
type: string
953+
format: date-time
954+
count:
955+
type: integer
956+
description: Total count of features.
957+
format: int64
958+
required:
959+
# For now, only require timestamp in case the definition
960+
# of the metric needs to change. Similar to WPTRunMetric.
961+
- timestamp
962+
BaselineStatusMetricsPage:
963+
type: object
964+
properties:
965+
metadata:
966+
$ref: '#/components/schemas/PageMetadata'
967+
data:
968+
type: array
969+
items:
970+
$ref: '#/components/schemas/BaselineStatusMetric'
971+
required:
972+
- data
906973
WPTRunMetric:
907974
type: object
908975
properties:

0 commit comments

Comments
 (0)