Skip to content

Commit 44e6a31

Browse files
authored
chore(api): small improvements (#3707)
1 parent bb85d82 commit 44e6a31

File tree

9 files changed

+209
-396
lines changed

9 files changed

+209
-396
lines changed

api/spec/lib/rules/friendly-name.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const friendlyNameRule = createRule({
1212
if (
1313
node.name &&
1414
!node.name.endsWith('Operations') &&
15+
!node.name.endsWith('Endpoints') &&
1516
!node.decorators.some((d) => d.decorator.name === '$friendlyName')
1617
) {
1718
context.reportDiagnostic({

api/spec/src/v3/common/error.tsp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,4 @@ model NotAvailable {
119119
@statusCode _: 503;
120120
}
121121

122-
alias ErrorResponses =
123-
| BadRequest
124-
| Unauthorized
125-
| Forbidden
126-
| Internal
127-
| NotAvailable;
122+
alias ErrorResponses = BadRequest | Unauthorized | Forbidden;

api/spec/src/v3/customers/operations.tsp

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,6 @@ model ListCustomersParamsFilter {
2525
key?: Shared.ExternalResourceKey;
2626
}
2727

28-
/**
29-
* Query params for listing customers.
30-
*/
31-
@friendlyName("ListCustomersParams")
32-
model ListCustomersParams {
33-
...Common.PagePaginationQuery;
34-
35-
/**
36-
* Sort customers returned in the response.
37-
* Supported sort attributes are:
38-
* - `id`
39-
* - `name` (default)
40-
* - `created_at`
41-
*
42-
* The `asc` suffix is optional as the default sort order is ascending.
43-
* The `desc` suffix is used to specify a descending order.
44-
*/
45-
@query(#{ name: "sort" })
46-
sort?: Common.SortQuery;
47-
48-
/**
49-
* Filter customers returned in the response.
50-
*
51-
* To filter customers by key add the following query param: filter[key]=my-db-id
52-
*/
53-
@query(#{ style: "deepObject", explode: true })
54-
filter?: ListCustomersParamsFilter;
55-
}
56-
5728
interface CustomersOperations {
5829
@post
5930
@operationId("create-customer")
@@ -80,7 +51,28 @@ interface CustomersOperations {
8051
@extension(Shared.UnstableExtension, true)
8152
@extension(Shared.InternalExtension, true)
8253
list(
83-
...ListCustomersParams,
54+
...Common.PagePaginationQuery,
55+
56+
/**
57+
* Sort customers returned in the response.
58+
* Supported sort attributes are:
59+
* - `id`
60+
* - `name` (default)
61+
* - `created_at`
62+
*
63+
* The `asc` suffix is optional as the default sort order is ascending.
64+
* The `desc` suffix is used to specify a descending order.
65+
*/
66+
@query(#{ name: "sort" })
67+
sort?: Common.SortQuery,
68+
69+
/**
70+
* Filter customers returned in the response.
71+
*
72+
* To filter customers by key add the following query param: filter[key]=my-db-id
73+
*/
74+
@query(#{ style: "deepObject", explode: true })
75+
filter?: ListCustomersParamsFilter,
8476
): Shared.PagePaginatedResponse<Customer> | Common.ErrorResponses;
8577

8678
@put

api/spec/src/v3/konnect.tsp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,23 @@ namespace MeteringAndBilling;
4444

4545
@route("/openmeter/events")
4646
@tag(Shared.EventsTag)
47-
@friendlyName("${Shared.MeteringAndBillingTitle}: ${Shared.EventsTag}")
4847
interface EventsEndpoints extends Events.EventsOperations {}
4948

5049
@route("/openmeter/meters")
5150
@tag(Shared.MetersTag)
52-
@friendlyName("${Shared.MeteringAndBillingTitle}: ${Shared.MetersTag}")
5351
interface MetersEndpoints extends Meters.MetersOperations {}
5452

5553
@route("/openmeter/customers")
5654
@tag(Shared.CustomersTag)
57-
@friendlyName("${Shared.MeteringAndBillingTitle}: ${Shared.CustomersTag}")
5855
interface CustomersEndpoints extends Customers.CustomersOperations {}
5956

6057
@route("/openmeter/customers/{customerId}/entitlement-access")
61-
@tag(Shared.CustomersTag)
6258
@tag(Shared.EntitlementsTag)
63-
@friendlyName("${Shared.MeteringAndBillingTitle}: ${Shared.EntitlementsTag}")
6459
interface CustomerEntitlementsEndpoints
6560
extends Entitlements.CustomerEntitlementsOperations {}
6661

6762
@route("/openmeter/subscriptions")
6863
@tag(Shared.SubscriptionsTag)
69-
@friendlyName("${Shared.MeteringAndBillingTitle}: ${Shared.SubscriptionsTag}")
7064
interface SubscriptionsEndpoints
7165
extends Subscriptions.SubscriptionsOperations {}
7266

api/spec/src/v3/openmeter.tsp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,22 @@ namespace OpenMeter;
4040

4141
@route("/openmeter/events")
4242
@tag(Shared.EventsTag)
43-
@friendlyName("${Shared.OpenMeterTitle}: ${Shared.EventsTag}")
4443
interface EventsEndpoints extends Events.EventsOperations {}
4544

4645
@route("/openmeter/meters")
4746
@tag(Shared.MetersTag)
48-
@friendlyName("${Shared.OpenMeterTitle}: ${Shared.MetersTag}")
4947
interface MetersEndpoints extends Meters.MetersOperations {}
5048

5149
@route("/openmeter/customers")
5250
@tag(Shared.CustomersTag)
53-
@friendlyName("${Shared.OpenMeterTitle}: ${Shared.CustomersTag}")
5451
interface CustomersEndpoints extends Customers.CustomersOperations {}
5552

5653
@route("/openmeter/customers/{customerId}/entitlement-access")
57-
@tag(Shared.CustomersTag)
5854
@tag(Shared.EntitlementsTag)
59-
@friendlyName("${Shared.OpenMeterTitle}: ${Shared.EntitlementsTag}")
6055
interface CustomerEntitlementsEndpoints
6156
extends Entitlements.CustomerEntitlementsOperations {}
6257

6358
@route("/openmeter/subscriptions")
6459
@tag(Shared.SubscriptionsTag)
65-
@friendlyName("${Shared.OpenMeterTitle}: ${Shared.SubscriptionsTag}")
6660
interface SubscriptionsEndpoints
6761
extends Subscriptions.SubscriptionsOperations {}

api/spec/src/v3/subscriptions/operations.tsp

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,6 @@ using TypeSpec.OpenAPI;
1212

1313
namespace Subscriptions;
1414

15-
/**
16-
* Query params for listing subscriptions.
17-
*/
18-
@friendlyName("ListSubscriptionsParams")
19-
model ListSubscriptionsParams {
20-
...Common.PagePaginationQuery;
21-
22-
/**
23-
* Sort subscriptions returned in the response.
24-
* Supported sort attributes are:
25-
* - `id`
26-
* - `created_at`
27-
*
28-
* The `asc` suffix is optional as the default sort order is ascending.
29-
* The `desc` suffix is used to specify a descending order.
30-
*/
31-
@query(#{ name: "sort" })
32-
sort?: Common.SortQuery;
33-
34-
/**
35-
* Filter subscriptions.
36-
*/
37-
@query(#{ style: "deepObject", explode: true })
38-
filter?: {
39-
/**
40-
* Filter subscriptions by customer ID.
41-
*/
42-
customer_id?: Shared.ULID;
43-
};
44-
}
45-
4615
/**
4716
* Request for canceling a subscription.
4817
*/
@@ -102,7 +71,18 @@ interface SubscriptionsOperations {
10271
@extension(Shared.UnstableExtension, true)
10372
@extension(Shared.InternalExtension, true)
10473
list(
105-
...ListSubscriptionsParams,
74+
...Common.PagePaginationQuery,
75+
76+
/**
77+
* Filter subscriptions.
78+
*/
79+
@query(#{ style: "deepObject", explode: true })
80+
filter?: {
81+
/**
82+
* Filter subscriptions by customer ID.
83+
*/
84+
customer_id?: Shared.ULID;
85+
},
10686
): Shared.PagePaginatedResponse<Subscription> | Common.NotFound | Common.ErrorResponses;
10787

10888
@get

api/spec/src/v3/subscriptions/subscription.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum SubscriptionEditTimingEnum {
3333
*/
3434
@oneOf
3535
@friendlyName("BillingSubscriptionEditTiming")
36+
@example(SubscriptionEditTimingEnum.immediate)
3637
union SubscriptionEditTiming {
3738
Enum: SubscriptionEditTimingEnum,
3839
Custom: Shared.DateTime,

0 commit comments

Comments
 (0)