Skip to content

Import/jsonname#141

Merged
fredbi merged 15 commits into
go-openapi:masterfrom
fredbi:import/jsonname
Jun 29, 2026
Merged

Import/jsonname#141
fredbi merged 15 commits into
go-openapi:masterfrom
fredbi:import/jsonname

Conversation

@fredbi

@fredbi fredbi commented Jun 29, 2026

Copy link
Copy Markdown
Member

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.

fredbi and others added 15 commits June 29, 2026 18:46
Follow-up on refactoring the swag API as more granular packages,
and deprecating the vast API currently exposed by swag.

All existing methods are maintained and work.

Existing configuration using global vars will continue to work at the
"swag" level: sub-packages no longer expose global variables.

Smaller packages will help maintain this very diverse set of features.

This API separates:
* loading : file loading utilities
* jsonutils, yamlutils: JSON & YAML document conversions

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
This clarifies the dependencies between the various utilities exposed by
this package.

Ultimately (not in this PR), we may convert some of the sub-packages
into go modules, so as to isolate dependencies and allow users of
some of the features not to be polluted by cross-dependencies.

* refactored mangling to remove package state

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
This PR transforms the "swag" package into a mono repo,
which exposes a collection of independant go modules.

The objective is to reduce the footprint of required dependencies.

To remain fully backward-compatible, the swag module imports all
the newly created (sub) modules, for programs that consume its
deprecated API.

ci: ci automation, test coverage reporting and dependabot configuration have been adapted to support
this new mono-repo structure.

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Linting
-------

* lint: updated linter config
* lint; golangci-lint no longer digs into sub-modules: we have
  to run the action explicitly with "working-directory"
* setup a matrix of submodules to lint all modules in this repo
* lint: relinted code

Auto-merging
-------

* ci(auto-merge): the issue with golang.org updates auto-merge rule
  is caused by the name of the group "golang.org-dependencies"
  is internally rewritten as a slug name "golang-org-dependencies"
  (with a dash, not a dot) so this no longer matches the triggering
  rules.
* ci(auto-merge): fixed the group name to replace "." by "-"
  (note: this fix should be propagated to all go-openapi repositories).

Mono-repo settings
-------

* hack: modified the tagging utility to support future modules declared
  at an arbitrary level in the hierarchy of folders.
* ci: introduced a new job to identify all sub-modules and produces the
  corresponding matrix for linting & testing each one independently.
* ci: introduced rendez-vous jobs for linting and testing so we can
  use only these two in branch protection rule requirements

Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
We want to remove this dependency by default, while still providing support to users who want to use easyjson.

* fixes go-openapi#68

This PR introduces an adapter to use ReadJSON and WriteJSON with
different supporting libraries. By default only the standard library
is enabled. A simple runtime registration allows the adapter to
support easyjson.

When import swag or swag/jsonutils or swag/yamlutils, easyjson is no longer a dependency:
JSON serialization only requires the standard library.

Supporting easyjson interfaces (e.g. for faster serialization) remains possible, by calling an independent module: swag/jsonutils/adapters/easyjson/json.Register().

1. ordered map w/stdlib
2. registry with stdlib as default
3. fixed int vs float64 rendering
4. beefed up tests, including integration tests
5. honed doc
6. more tests

TODO:
* [x] hone test coverage
* benchmarks
* profiling

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
This PR prepares the forthcoming release. We need to tidy up a little
bit the way the mono-repo setup is handled.

This starts by embracing `go.work`.

Content
=======

* added go.work declaration
* ci: adapted go tests to go.work. This should dramatically reduce the
  number of test jobs. At this moment, we still lint go modules in
  independent jobs.
* ci: fixed issue with go mod caching
* fix: dependabot not being able to update nested modules
* updated stretchr/testify dependency (because dependabot didn't succeed
  doing so previously)
* removed replace directives from top-level module. We still to keep the
  replace directives in sub-modules. These will disappear when we cut
  the next release.
* doc (updated TODO items list)

adapter tagger script to go.work

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
* switch to forked testify (go-openapi/testify/v2) which no longer
  imports external dependencies
* all test dependencies now boil down to go-openapi/testify/v2

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
This commit replaces the full license terms in each go source file
by the more compact SPDX annotations (i.e. 2 lines instead of 13).

All go files now embed these summarized licensing terms.

Also:
* license is now cited in README

Aside:
* fixed sample code in README on how to register an adapter

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Signed-off-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
…ries with 2 updates

Signed-off-by: dependabot[bot] <support@github.com>
…nventions for JSON (#195)

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
…ries with 2 updates

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.16256% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.34%. Comparing base (1bdadef) to head (ae73433).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
jsonname/go_name_provider.go 89.85% 10 Missing and 4 partials ⚠️
jsonname/name_provider.go 87.69% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #141      +/-   ##
==========================================
- Coverage   89.43%   89.34%   -0.10%     
==========================================
  Files           3        5       +2     
  Lines         388      591     +203     
==========================================
+ Hits          347      528     +181     
- Misses         24       38      +14     
- Partials       17       25       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@fredbi fredbi merged commit 3663b09 into go-openapi:master Jun 29, 2026
20 of 21 checks passed
@fredbi fredbi deleted the import/jsonname branch June 29, 2026 16:56
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