Skip to content

Commit 7287cd3

Browse files
[#PE-756] Updated CGN search api and added a new /count endpoint (#1164)
1 parent d70b2a1 commit 7287cd3

File tree

8 files changed

+305
-96
lines changed

8 files changed

+305
-96
lines changed

api_cgn_operator_search.yaml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ paths:
2929
schema:
3030
$ref: "#/definitions/ProblemJson"
3131

32+
"/count":
33+
get:
34+
operationId: count
35+
summary: Count merchants and discounts to search within
36+
description: |
37+
Count merchants and discountsto search within
38+
responses:
39+
"200":
40+
description: Count of merchants/discounts
41+
schema:
42+
$ref: "#/definitions/CountResult"
43+
"400":
44+
description: Bad request.
45+
"401":
46+
description: Login expired.
47+
"500":
48+
description: Service unavailable.
49+
schema:
50+
$ref: "#/definitions/ProblemJson"
51+
3252
"/search":
3353
post:
3454
operationId: search
@@ -172,49 +192,51 @@ definitions:
172192
ProblemJson:
173193
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v21.0.1/openapi/definitions.yaml#/ProblemJson"
174194
Merchant:
175-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Merchant"
195+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Merchant"
176196
SupportType:
177-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SupportType"
197+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SupportType"
178198
DiscountCodeType:
179-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/DiscountCodeType"
199+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/DiscountCodeType"
180200
OfflineMerchants:
181-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchants"
201+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchants"
182202
OfflineMerchant:
183-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchant"
203+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchant"
184204
OfflineMerchantSearchRequest:
185-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
205+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
206+
CountResult:
207+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/CountResult"
186208
SearchResult:
187-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
209+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
188210
SearchItem:
189-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
211+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
190212
OnlineMerchants:
191-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchants"
213+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchants"
192214
OnlineMerchant:
193-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchant"
215+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchant"
194216
SearchRequest:
195-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
217+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
196218
OnlineMerchantSearchRequest:
197-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
219+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
198220
Discount:
199-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Discount"
221+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Discount"
200222
ProductCategory:
201-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/ProductCategory"
223+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/ProductCategory"
202224
Address:
203-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Address"
225+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Address"
204226
Coordinates:
205-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Coordinates"
227+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Coordinates"
206228
BoundingBox:
207-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/BoundingBox"
229+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/BoundingBox"
208230
DiscountBucketCode:
209-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/DiscountBucketCode"
231+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/DiscountBucketCode"
210232
PublishedProductCategories:
211-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategories"
233+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategories"
212234
PublishedProductCategoriesWithNewDiscountsCount:
213-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
235+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
214236
PublishedProductCategoriesResult:
215-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
237+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
216238
ProductCategoryWithNewDiscountsCount:
217-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
239+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
218240
securityDefinitions:
219241
Bearer:
220242
type: apiKey

openapi/api_cgn_operator_search.template.yaml

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ paths:
2828
description: Service unavailable.
2929
schema:
3030
$ref: "#/definitions/ProblemJson"
31+
"/count":
32+
get:
33+
operationId: count
34+
summary: Count merchants and discounts to search within
35+
description: |
36+
Count merchants and discountsto search within
37+
responses:
38+
"200":
39+
description: Count of merchants/discounts
40+
schema:
41+
$ref: "#/definitions/CountResult"
42+
"400":
43+
description: Bad request.
44+
"401":
45+
description: Login expired.
46+
"500":
47+
description: Service unavailable.
48+
schema:
49+
$ref: "#/definitions/ProblemJson"
3150
"/search":
3251
post:
3352
operationId: search
@@ -165,49 +184,51 @@ definitions:
165184
ProblemJson:
166185
$ref: "../node_modules/@pagopa/io-functions-commons/openapi/definitions.yaml#/ProblemJson"
167186
Merchant:
168-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Merchant"
187+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Merchant"
169188
SupportType:
170-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/SupportType"
189+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/SupportType"
171190
DiscountCodeType:
172-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/DiscountCodeType"
191+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/DiscountCodeType"
173192
OfflineMerchants:
174-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchants"
193+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchants"
175194
OfflineMerchant:
176-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchant"
195+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchant"
177196
OfflineMerchantSearchRequest:
178-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
197+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
198+
CountResult:
199+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/CountResult"
179200
SearchResult:
180-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
201+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
181202
SearchItem:
182-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
203+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
183204
OnlineMerchants:
184-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchants"
205+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchants"
185206
OnlineMerchant:
186-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchant"
207+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchant"
187208
SearchRequest:
188-
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
209+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
189210
OnlineMerchantSearchRequest:
190-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
211+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
191212
Discount:
192-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Discount"
213+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Discount"
193214
ProductCategory:
194-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/ProductCategory"
215+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/ProductCategory"
195216
Address:
196-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Address"
217+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Address"
197218
Coordinates:
198-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Coordinates"
219+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Coordinates"
199220
BoundingBox:
200-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/BoundingBox"
221+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/BoundingBox"
201222
DiscountBucketCode:
202-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/DiscountBucketCode"
223+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/DiscountBucketCode"
203224
PublishedProductCategories:
204-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategories"
225+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategories"
205226
PublishedProductCategoriesWithNewDiscountsCount:
206-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
227+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
207228
PublishedProductCategoriesResult:
208-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
229+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
209230
ProductCategoryWithNewDiscountsCount:
210-
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
231+
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
211232
securityDefinitions:
212233
Bearer:
213234
type: apiKey

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"generate:proxy:cgn-operator-search-models": "rimraf generated/cgn-operator-search && gen-api-models --api-spec api_cgn_operator_search.yaml --out-dir generated/cgn-operator-search",
4747
"generate:api:io-bonus": "rimraf generated/io-bonus-api && gen-api-models --api-spec openapi/consumed/fn_bonus.yaml --no-strict --out-dir generated/io-bonus-api --request-types --response-decoders --client",
4848
"generate:api:io-sign": "rimraf generated/io-sign-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-sign/0a9124b7c782b2569dd82c094496e50a17b418f4/apps/io-func-sign-user/openapi.yaml --no-strict --out-dir generated/io-sign-api --request-types --response-decoders --client",
49-
"generate:api:io-cgn-operator-search": "rimraf generated/io-cgn-operator-search-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml --no-strict --out-dir generated/io-cgn-operator-search-api --request-types --response-decoders --client",
49+
"generate:api:io-cgn-operator-search": "rimraf generated/io-cgn-operator-search-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml --no-strict --out-dir generated/io-cgn-operator-search-api --request-types --response-decoders --client",
5050
"generate:api:pagopaproxy": "rimraf generated/pagopa-proxy && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v1.6.0/api-spec/api-for-io.yaml --no-strict --out-dir generated/pagopa-proxy --request-types --response-decoders --client",
5151
"generate:api:lollipop": "rimraf generated/lollipop-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-lollipop/724c3ba79d272d4e2555dbc2a8e1657bec9f84ce/openapi/internal.yaml --no-strict --out-dir generated/lollipop-api --request-types --response-decoders --client",
5252
"generate:api:services-app-backend": "rimraf generated/services-app-backend && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-services-cms/d2afbdf73e5b4ffd24aa46b025729ff2a9ed3cce/apps/app-backend/api/internal.yaml --no-strict --out-dir generated/services-app-backend --request-types --response-decoders --client",

src/app.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,12 @@ function registerCgnOperatorSearchAPIRoutes(
11861186
toExpressHandler(cgnOperatorController.getMerchant, cgnOperatorController)
11871187
);
11881188

1189+
app.get(
1190+
`${basePath}/count`,
1191+
bearerSessionTokenAuth,
1192+
toExpressHandler(cgnOperatorController.count, cgnOperatorController)
1193+
);
1194+
11891195
app.post(
11901196
`${basePath}/search`,
11911197
bearerSessionTokenAuth,

0 commit comments

Comments
 (0)