v2.1.0: Nullable, external reference improvements, x-order, and many more! #1443
jamietanna
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
🔊 Notable features
Nullable
typesIt's possible that you want to be able to determine whether a field isn't sent, is sent as
null
or has a value.For instance, if you had the following OpenAPI property:
The current behaviour in oapi-codegen is to generate:
However, you lose the ability to understand the three cases, as there's no way to distinguish two of the types from each other:
S.Field == nil
)null
? (Can be checked withS.Field == nil
)S.Field != nil && *S.Field == "123"
)Therefore, as requested in #1039, this is now possible to represent with the
nullable.Nullable
type from our new library, oapi-codegen/nullable.If you configure your generator's Output Options as so:
You will now receive the following output:
Note that this is opt-in only, due to it being a break in existing signatures and behaviour.
You can find out more about how this works in a blog post with further details.
External references are now handled better
A big change has come in which handling of external references (also called import mappings) is much more resilient and predictable for generated code.
This allows cases where multiple files referencing each other (for instance if you've split your API across multiple files, and join them using
$ref
s) now correctly generate code.There are a few cases that won't be covered, that we'll complete in #1440 but until then, it hopefully should work better.
Thank you to Ejendomstorvet for sponsoring this work.
🚀 New features and improvements
nullable.Nullable
for nullable properties (Allow generatingnullable.Nullable
for nullable properties #1404) @sonasingh46IsMediaTypeJson
(Support media type parameters forIsMediaTypeJson
#1386) @jamietanna.Required
toBindStyledParameterWithLocation
andBindStyledParameter
(Pass.Required
toBindStyledParameterWithLocation
andBindStyledParameter
#1315) @renom🐛 Bug fixes
os.Exit(1)
only frommain()
(refactor(cmd): Useos.Exit(1)
only frommain()
#1398) @alexandear.Required
toBindStyledParameterWithLocation
andBindStyledParameter
(Pass.Required
toBindStyledParameterWithLocation
andBindStyledParameter
#1315) @renom📝 Documentation updates
import-mapping
with URLs (Document how to useimport-mapping
with URLs #1428) @jamietanna👻 Maintenance
📦 Dependency updates
New Contributors
.Required
toBindStyledParameterWithLocation
andBindStyledParameter
#1315This discussion was created from the release v2.1.0: Nullable, external reference improvements, x-order, and many more!.
Beta Was this translation helpful? Give feedback.
All reactions