Skip to content

Add tests for /api/v1/locations/{language} endpoint#98

Merged
Jonathan-Zollinger merged 12 commits into
mainfrom
madsen/support-locations
May 19, 2026
Merged

Add tests for /api/v1/locations/{language} endpoint#98
Jonathan-Zollinger merged 12 commits into
mainfrom
madsen/support-locations

Conversation

@ZeterTheDuck
Copy link
Copy Markdown
Contributor

This also adds the needed schema for generated classes in the schema.yml file.

@Jonathan-Zollinger Jonathan-Zollinger self-requested a review May 18, 2026 19:37
Copy link
Copy Markdown
Member

@Jonathan-Zollinger Jonathan-Zollinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really great work! a few changes, but this would have been a great PR without these changes as well - great work!

- Image
- User
- Organization
- Project
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Project
- Location
- Locale

Comment thread core/src/main/resources/schema.yml Outdated
Comment on lines +2031 to +2044
CountryStatePair:
type: object
properties:
countryInfo:
$ref: "#/components/schemas/CountryInfo"
country:
type: string
nullable: true
state:
type: string
nullable: true
county:
type: string
nullable: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take this opportunity to improve on this name since it's not really a 'pair'. I'm interested to hear your suggestions, but maybe something along the lines of "CountryContext" as it's more accurate to its name?

Comment on lines +2018 to +2030
CountryInfo:
type: object
properties:
twoCharCode:
type: string
nullable: true
threeCharCode:
type: string
nullable: true
countryPhone:
type: string
nullable: true
additionalProperties: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another opportunity to have this make more sense than what we originally inherited - let's go with 'CountryIdentifiers'. When I first read "country info", I was thinking I'd see data about the country at a high level, but it's specifically identifiers and nothing more.

type: object
properties:
twoCharCode:
type: string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: string
type: string
description: "ISO 3166-1 standard two letter country code"

type: string
nullable: true
threeCharCode:
type: string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: string
type: string
description: "ISO 3166-1 standard three letter country code"

Comment thread core/src/main/resources/schema.yml Outdated
get:
tags: [ Location ]
description: Get all locations in a language
operationId: getLanguage
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: getLanguage
operationId: getLocation

Comment thread core/src/main/resources/schema.yml Outdated
schema:
type: array
items:
$ref: "#/components/schemas/CountryStatePair"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comments on 2044

application/json:
schema:
$ref: '#/components/schemas/ImageUploadResponse'
/api/v1/locations/{language}:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add the GET Languages endpoint for our tests

Suggested change
/api/v1/locations/{language}:
/api/v1/languages:
get:
tags:
- Language
responses:
"200":
description: OK
content:
text/plain:
schema:
type: array
items:
$ref: "#/components/schemas/LocaleNames"
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/LocaleNames"
text/json:
schema:
type: array
items:
$ref: "#/components/schemas/LocaleNames"
/api/v1/locations/{language}:

nullable: true
county:
type: string
nullable: true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nullable: true
nullable: true
LocaleNames:
type: object
properties:
bcp47:
description: locale abbreviation per the <a href='https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag' BCP 47 standard</a>
type: string
nullable: true
name:
description: locale name
type: string
nullable: true

for the name field, can you see if it returns the three char code that would map to the field on line 2024 or if it's a human-readable field? if it's meant to be the three char field, let's document it as such.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigating to stage.justserve.org, it appears that the name is a human-readable field. I'll also add the "lang3char" field that you missed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check what the response is in stage - the swagger docs I'm using may be outdated but they only reference the two fields I've added above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure if these are going to be usable, because the lang3char field does not seem to follow any standardized format. For instance, French is "fre", which matches the older legacy code for ISO 639, but Portuguese is "prt", which isn't at all used in ISO 639, but used in ISO 3166 for Portugal. However, "fre" is not present in ISO 3166. So there would have to be some more in-depth restructuring to use these.

You can see what's available by going to /api/languages

Copy link
Copy Markdown
Member

@Jonathan-Zollinger Jonathan-Zollinger May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove the iso description from them then, but still add some helpful docs (just without the iso reference). I wish we knew the rhyme or reason for the different strings

Comment on lines +49 to +69
def "result data from .../locations/{language} matches expected format"() {
given:
def lang = "eng"

when:
def location = locationClient.getLanguage(lang).block().first

then:
verifyAll {
location != null
location.getCountryInfo() != null

location.getCountryInfo().getTwoCharCode() == null || location.getCountryInfo().getTwoCharCode() ==~ /[a-z]{2}/
location.getCountryInfo().getThreeCharCode() == null || location.getCountryInfo().getThreeCharCode() ==~ /[a-z]{3}/
location.getCountryInfo().getCountryPhone() == null || location.getCountryInfo().getCountryPhone() ==~ /\d+/
location.getCountry() == null || location.getCountry() ==~ /.+/
location.getState() == null || location.getState() ==~ /.+/
location.getCounty() == null || location.getCounty() ==~ /.+/
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow the same edits as the test above.

@Jonathan-Zollinger Jonathan-Zollinger merged commit 04c1efb into main May 19, 2026
1 check failed
@Jonathan-Zollinger Jonathan-Zollinger deleted the madsen/support-locations branch May 19, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants