Skip to content

Openapi generator minor improvements#3511

Open
Silvanoc wants to merge 10 commits into
mainfrom
openapi-generator-minor-improvements
Open

Openapi generator minor improvements#3511
Silvanoc wants to merge 10 commits into
mainfrom
openapi-generator-minor-improvements

Conversation

@Silvanoc
Copy link
Copy Markdown
Contributor

@Silvanoc Silvanoc commented May 12, 2026

Summary

  • Removed inert LifecycleMixin inheritance
  • Fixed file handle leak in serialize()
  • Added class docstring and missing type hints on private methods
  • Made --template CLI option required; added input validation for template structure (missing paths/components, pre-existing components/schemas)
  • Fixed inconsistent $defs → components/schemas string replacement
  • Fixed typos in CLI help and test comments
  • Added tests for all three JSON Schema → OpenAPI transformations ($defs refs, const → enum, nullable type → anyOf)
  • Extracted shared test fixture for DRY

How was this tested?

New added tests.

Areas of uncertainty

Minor changes.

Checklist

  • My code follows the contributor guidelines
  • I have added tests that prove my fix/feature works
  • Existing tests pass locally with my changes

AI Assistance

If you used AI tools while preparing this PR, you are still the author and responsible for understanding, verifying, and defending your submission. Please engage with reviewers personally rather than through your agent during feedback and revisions. See our AI Covenant for details.

Silvanoc added 7 commits May 12, 2026 15:41
No use of the LifecycleMixin hooks, removing that unneeded inheritance.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Using a context manager to ensure that the OpenAPI generator closes the
template file once read.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Add docstring describing what the OpenApiGenerator class does.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
The template is required, ensuring its presence at both CLI and class
level.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Do some basic sanity checks on the template.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Make replacement of `components/schemas` in the template consistent and
more readable.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 84.21053% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.35%. Comparing base (1c5f68e) to head (73abb58).

Files with missing lines Patch % Lines
...ackages/linkml/src/linkml/generators/openapigen.py 84.21% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3511      +/-   ##
==========================================
+ Coverage   80.96%   84.35%   +3.39%     
==========================================
  Files         157      157              
  Lines       18658    18667       +9     
  Branches     3931     3935       +4     
==========================================
+ Hits        15106    15747     +641     
+ Misses       2696     2014     -682     
- Partials      856      906      +50     
Flag Coverage Δ
linkml 80.93% <84.21%> (-0.02%) ⬇️
runtime 80.92% <84.21%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Silvanoc Silvanoc force-pushed the openapi-generator-minor-improvements branch from 9846b61 to 02903eb Compare May 12, 2026 17:44
Silvanoc added 2 commits May 12, 2026 23:05
Class title and description where being removed. But only title should
be removed because that is exactly the dictionary entry value in the
resulting JSON-Schema. But description should be kept. This patch fixes
it.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Add additional tests to reduce issues in future changes.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
@Silvanoc Silvanoc force-pushed the openapi-generator-minor-improvements branch from 02903eb to c2d3cde Compare May 12, 2026 21:05
@Silvanoc Silvanoc marked this pull request as ready for review May 12, 2026 21:24
@Silvanoc
Copy link
Copy Markdown
Contributor Author

Silvanoc commented May 12, 2026

This PR addresses comments raised by @amc-corey-cox on PR #3300 and not addressed before merging and adds some additional minor improvements.

Dump to a "better looking" version. Previous version (v0.0.1) was too
alphaish. This patch bumps the version to a more stable looking one
(v0.1.0).

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants