Skip to content

feat: new formats for currencies (ISO-4217 alpha-3) and countries (ISO-3166 alpha-3 & alpha-2)#285

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/58-currency
Jul 14, 2026
Merged

feat: new formats for currencies (ISO-4217 alpha-3) and countries (ISO-3166 alpha-3 & alpha-2)#285
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/58-currency

Conversation

@fredbi

@fredbi fredbi commented Jul 14, 2026

Copy link
Copy Markdown
Member

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

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

…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

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.11111% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.97%. Comparing base (a9ba012) to head (8605915).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
country.go 65.00% 26 Missing and 2 partials ⚠️
currency.go 58.06% 24 Missing and 2 partials ⚠️
mongo.go 0.00% 22 Missing ⚠️
conv/default.go 0.00% 12 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

@fredbi fredbi changed the title feat: new formats for currencies (ISO-4217 alpha-3) and countries (IS… feat: new formats for currencies (ISO-4217 alpha-3) and countries (ISO-3166 alpha-3 & alpha-2) Jul 14, 2026
@fredbi
fredbi merged commit 12fcdc1 into go-openapi:master Jul 14, 2026
26 of 28 checks passed
@fredbi
fredbi deleted the feat/58-currency branch July 14, 2026 17:52
Comment thread internal/countries/gen.go
"sort"
)

//go:embed iso3166.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah we are living a period where more countries are disappearing than new ones are created...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok. I'll add some attribution. this is the iso list I don't think it deserves credits/attributions right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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"

Comment thread country.go
Comment on lines +102 to +111
func (u Country) String() string {
switch u.l {
case alpha3Len:
return u.ISOAlpha3
case alpha2Len:
return u.ISOAlpha2
default:
return ""
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the name "France" is resolved in the embedded type, but not used for wire-serialization

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the name "France" is resolved in the embedded type, but not used for wire-serialization

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

so you have to use Country.Name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread country.go
@@ -0,0 +1,173 @@
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could have updated to use 2026, even if I know copyright date ranges are usually misunderstood

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we've been there already, don't recall it?

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.

Support for ISO 3166-1 alpha-2 country codes

2 participants