feat: new formats for currencies (ISO-4217 alpha-3) and countries (ISO-3166 alpha-3 & alpha-2)#285
Conversation
…O-3166 alpha-3 & alpha-2) These formats are non-standard additions (for jsonschema or openapi) but support well-known standards. * closes go-openapi#58 Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (51.11%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #285 +/- ##
==========================================
- Coverage 88.22% 85.97% -2.26%
==========================================
Files 22 24 +2
Lines 2778 2958 +180
==========================================
+ Hits 2451 2543 +92
- Misses 221 305 +84
- Partials 106 110 +4 ☔ View full report in Codecov by Harness. |
| "sort" | ||
| ) | ||
|
|
||
| //go:embed iso3166.json |
There was a problem hiding this comment.
What is the source of this file?
Is it explained how you got it and to update it.
I know new country addition is pretty rare anyway
There was a problem hiding this comment.
yeah we are living a period where more countries are disappearing than new ones are created...
There was a problem hiding this comment.
ok. I'll add some attribution. this is the iso list I don't think it deserves credits/attributions right?
There was a problem hiding this comment.
It's more about
"I got the file here"
It's only for credits,but for contributirs who may argue "but my country is not listed"
| func (u Country) String() string { | ||
| switch u.l { | ||
| case alpha3Len: | ||
| return u.ISOAlpha3 | ||
| case alpha2Len: | ||
| return u.ISOAlpha2 | ||
| default: | ||
| return "" | ||
| } | ||
| } |
There was a problem hiding this comment.
I can see you use String everywhere (Marshal and others), which makes unserializaton and serialization stable
But as a user, when you get a country with FRA or FR and send it to your lib, I would expect to get France
There was a problem hiding this comment.
the name "France" is resolved in the embedded type, but not used for wire-serialization
There was a problem hiding this comment.
the name "France" is resolved in the embedded type, but not used for wire-serialization
There was a problem hiding this comment.
so you have to use Country.Name
There was a problem hiding this comment.
Yes, but why String would return you passed to the lib.
Maybe you should mention the lib is is made for being idempotent. It might be cleaer why FRA is returned when you pass FRA, either in string, JSON
| @@ -0,0 +1,173 @@ | |||
| // SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers | |||
There was a problem hiding this comment.
You could have updated to use 2026, even if I know copyright date ranges are usually misunderstood
There was a problem hiding this comment.
we've been there already, don't recall it?
These formats are non-standard additions (for jsonschema or openapi) but support well-known standards.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist