diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 9fb5ab4..9b24595 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -311,8 +311,13 @@ paths: type: array items: $ref: '#/components/schemas/CityCouncilDistrict' + order: + type: string + description: City council districts ids are sorted as if numbers in ascending order + example: 'id' required: - cityCouncilDistricts + - order '400': $ref: '#/components/responses/BadRequest' '500': @@ -1067,8 +1072,8 @@ components: id: type: string description: One or two character code to represent city council districts. - pattern: '^([0-9]{1,2})$' - example: 25 + pattern: '^([0-9]{1,2})$' + example: '25' required: - id CityCouncilDistrictGeoJson: diff --git a/src/city-council-district/city-council-district.repository.ts b/src/city-council-district/city-council-district.repository.ts index 9618aaf..8a42964 100644 --- a/src/city-council-district/city-council-district.repository.ts +++ b/src/city-council-district/city-council-district.repository.ts @@ -50,6 +50,7 @@ export class CityCouncilDistrictRepository { columns: { id: true, }, + orderBy: sql`${cityCouncilDistrict.id}::integer ASC`, }); } catch { throw new DataRetrievalException(); diff --git a/src/city-council-district/city-council-district.service.spec.ts b/src/city-council-district/city-council-district.service.spec.ts index 5e016a3..92e172b 100644 --- a/src/city-council-district/city-council-district.service.spec.ts +++ b/src/city-council-district/city-council-district.service.spec.ts @@ -37,6 +37,8 @@ describe("City Council District service unit", () => { expect(() => findCityCouncilDistrictsQueryResponseSchema.parse(cityCouncilDistricts), ).not.toThrow(); + + expect(cityCouncilDistricts.order).toBe("id"); }); }); diff --git a/src/city-council-district/city-council-district.service.ts b/src/city-council-district/city-council-district.service.ts index 060d571..7aacbb3 100644 --- a/src/city-council-district/city-council-district.service.ts +++ b/src/city-council-district/city-council-district.service.ts @@ -27,6 +27,7 @@ export class CityCouncilDistrictService { return { cityCouncilDistricts, + order: "id", }; } diff --git a/src/gen/schemas/CityCouncilDistrict.json b/src/gen/schemas/CityCouncilDistrict.json index 0cec1d1..5a63b58 100644 --- a/src/gen/schemas/CityCouncilDistrict.json +++ b/src/gen/schemas/CityCouncilDistrict.json @@ -4,7 +4,7 @@ "id": { "description": "One or two character code to represent city council districts.", "type": "string", - "example": 25, + "example": "25", "pattern": "^([0-9]{1,2})$" } }, diff --git a/src/gen/schemas/CityCouncilDistrictGeoJson.json b/src/gen/schemas/CityCouncilDistrictGeoJson.json index d92cacc..7aad020 100644 --- a/src/gen/schemas/CityCouncilDistrictGeoJson.json +++ b/src/gen/schemas/CityCouncilDistrictGeoJson.json @@ -14,7 +14,7 @@ "id": { "description": "One or two character code to represent city council districts.", "type": "string", - "example": 25, + "example": "25", "pattern": "^([0-9]{1,2})$" } }, diff --git a/src/gen/types/FindCityCouncilDistricts.ts b/src/gen/types/FindCityCouncilDistricts.ts index 564cd44..4e1aa34 100644 --- a/src/gen/types/FindCityCouncilDistricts.ts +++ b/src/gen/types/FindCityCouncilDistricts.ts @@ -9,6 +9,11 @@ export type FindCityCouncilDistricts200 = { * @type array */ cityCouncilDistricts: CityCouncilDistrict[]; + /** + * @description City council districts ids are sorted as if numbers in ascending order + * @type string + */ + order: string; }; /** * @description Invalid client request @@ -26,6 +31,11 @@ export type FindCityCouncilDistrictsQueryResponse = { * @type array */ cityCouncilDistricts: CityCouncilDistrict[]; + /** + * @description City council districts ids are sorted as if numbers in ascending order + * @type string + */ + order: string; }; export type FindCityCouncilDistrictsQuery = { Response: FindCityCouncilDistrictsQueryResponse; diff --git a/src/gen/zod/findCityCouncilDistrictsSchema.ts b/src/gen/zod/findCityCouncilDistrictsSchema.ts index feb0333..d153825 100644 --- a/src/gen/zod/findCityCouncilDistrictsSchema.ts +++ b/src/gen/zod/findCityCouncilDistrictsSchema.ts @@ -7,6 +7,11 @@ import { errorSchema } from "./errorSchema"; */ export const findCityCouncilDistricts200Schema = z.object({ cityCouncilDistricts: z.array(z.lazy(() => cityCouncilDistrictSchema)), + order: z.coerce + .string() + .describe( + "City council districts ids are sorted as if numbers in ascending order", + ), }); /** * @description Invalid client request @@ -21,4 +26,9 @@ export const findCityCouncilDistricts500Schema = z.lazy(() => errorSchema); */ export const findCityCouncilDistrictsQueryResponseSchema = z.object({ cityCouncilDistricts: z.array(z.lazy(() => cityCouncilDistrictSchema)), + order: z.coerce + .string() + .describe( + "City council districts ids are sorted as if numbers in ascending order", + ), });