diff --git a/core/src/main/resources/schema.yml b/core/src/main/resources/schema.yml index 69fb5c9..ab18788 100644 --- a/core/src/main/resources/schema.yml +++ b/core/src/main/resources/schema.yml @@ -84,7 +84,68 @@ paths: type: array items: $ref: "#/components/schemas/CountryContext" - /api/v1/locations/{parentId}/{locale}: + /api/v1/locations/{language}/address/{address}: + get: + description: Get a location by an address + operationId: getLocationByAddress + tags: + [ Location ] + parameters: + - name: language + in: path + required: true + schema: + type: string + - name: address + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + text/plain: + schema: + $ref: "#/components/schemas/Location" + application/json: + schema: + $ref: "#/components/schemas/Location" + text/json: + schema: + $ref: "#/components/schemas/Location" + /api/v1/locations/{language}/countries: + get: + description: Get a list of all countries, in a certain language + operationId: getCountries + tags: + [ Location ] + parameters: + - name: language + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + text/plain: + schema: + type: array + items: + type: string + applications/json: + schema: + type: array + items: + type: string + text/json: + schema: + type: array + items: + type: string + /api/v1/locations/chidren/{parentId}/{locale}: get: description: Get the children of a parent location, in a certain locale operationId: getCivicChild @@ -1128,39 +1189,100 @@ components: additionalProperties: false Location: type: object - properties: { latitude: { type: number, format: double }, - longitude: { type: number, format: double } } - additionalProperties: false - LocationWithRadius: - type: object, + description: "Representation of a real-world location" properties: - mapId: { type: string, nullable: true } - fullDisplayAddress: { type: string, nullable: true } - address: { type: string, nullable: true } - suite: { type: string, nullable: true } - city: { type: string, nullable: true } - civicCityId: { type: string, format: uuid, nullable: true } - neighborhood: { type: string, nullable: true } - county: { type: string, nullable: true } - state: { type: string, nullable: true } - postal: { type: string, nullable: true } - country: { type: string, nullable: true } - countryCode: { type: string, nullable: true } - missionId: { type: string, nullable: true } - ccId: { type: string, nullable: true } - stakeId: { type: string, nullable: true } - areaId: { type: string, nullable: true } - latitude: { type: number, format: double } - longitude: { type: number, format: double } - maxLatitude: { type: number, format: double } - minLatitude: { type: number, format: double } - maxLongitude: { type: number, format: double } - minLongitude: { type: number, format: double } - geoCodeOverride: { type: boolean } - timezone: { type: string, nullable: true } - radiusType: { $ref: '#/components/schemas/DistanceType' } - countryCode2Char: { type: string, nullable: true } + mapId: + type: string + nullable: true + fullDisplayAddress: + description: "Full representation of this location's address" + type: string + nullable: true + address: + description: "Primary street address" + type: string + nullable: true + suite: + description: "Additional address details" + type: string + nullable: true + city: + type: string + nullable: true + civicCityId: + type: string + format: uuid + nullable: true + neighborhood: + type: string + nullable: true + county: + type: string + nullable: true + state: + type: string + nullable: true + postal: + type: string + nullable: true + country: + type: string + nullable: true + countryCode: + description: "ISO 3166-1 standard three-letter country code" + type: string + nullable: true + locationVisibilityId: + type: integer + format: int32 + missionId: + type: string + nullable: true + ccId: + type: string + nullable: true + stakeId: + type: string + nullable: true + areaId: + type: string + nullable: true + latitude: + type: number + format: double + longitude: + type: number + format: double + maxLatitude: + type: number + format: double + minLatitude: + type: number + format: double + maxLongitude: + type: number + format: double + minLongitude: + type: number + format: double + geoCodeOverride: + type: boolean + timezone: + type: string + nullable: true additionalProperties: false + LocationWithRadius: + description: "Representation of an area in the vicinity of a real-world location" + allOf: + - $ref: '#/components/schemas/Location' + - type: object + properties: + radiusType: { $ref: '#/components/schemas/DistanceType' } + countryCode2Char: + description: "ISO 3166-1 standard two-letter country code" + type: string + nullable: true + additionalProperties: false VolunteerCenterInfo: type: object properties: @@ -2040,8 +2162,9 @@ components: format: uuid logo: type: string - CountryInfo: + CountryBasicIdentifiers: type: object + description: "Basic standardized identifiers for a country." properties: twoCharCode: type: string @@ -2060,14 +2183,19 @@ components: type: object properties: countryInfo: - $ref: "#/components/schemas/CountryInfo" + allOf: + - $ref: "#/components/schemas/CountryBasicIdentifiers" + description: "Basic standardized identifiers for a country. Should be named countryBasicIdentifiers to avoid confusion, but maintain JSON property 'countryInfo'" country: + description: "Name of the country" type: string nullable: true state: + description: "A principal subdivision of a country" type: string nullable: true county: + description: "A smaller subdivision of a state" type: string nullable: true LocaleNames: diff --git a/core/src/test/groovy/org/justserve/LocationSpec.groovy b/core/src/test/groovy/org/justserve/LocationSpec.groovy index d322c9f..24a74a9 100644 --- a/core/src/test/groovy/org/justserve/LocationSpec.groovy +++ b/core/src/test/groovy/org/justserve/LocationSpec.groovy @@ -38,4 +38,29 @@ class LocationSpec extends JustServeSpec { [[client, userType], lang] << [[[noAuthLocationClient, "no auth"], [locationClient, "standard"]], threeCharLocales].combinations() } + @SuppressWarnings("GroovyAssignabilityCheck") + @Unroll("Can query LocationClient.getCountries(#lang) with no error as #userType") + def "can query countries with by a given language"(LocationClient client, String userType, String lang){ + when: + client.getCountries(lang).block() + + then: + noExceptionThrown() + + where: + [[client, userType], lang] << [[[noAuthLocationClient, "no auth"], [locationClient, "standard"]], threeCharLocales].combinations() + } + + @SuppressWarnings("GroovyAssignabilityCheck") + @Unroll("Can query LocationClient.getLocationByAddress(#lang, address) for a known working location with no error as #userType") + def "can query location by address for a given language"(LocationClient client, String userType, String lang){ + when: + client.getLocationByAddress(lang, knownWorkingLocation).block() + + then: + noExceptionThrown() + + where: + [[client, userType], lang] << [[[noAuthLocationClient, "no auth"], [locationClient, "standard"]], threeCharLocales].combinations() + } }