Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to access a single extension to Extensible #666

Open
MikeEdgar opened this issue Oct 18, 2024 · 0 comments
Open

Add methods to access a single extension to Extensible #666

MikeEdgar opened this issue Oct 18, 2024 · 0 comments

Comments

@MikeEdgar
Copy link
Member

Retrieving an extension via Extensible currently requires the use of getExtensions to acquire the entire extension map, which can then be used to pick the single entry. We should add getExtension(String) and hasExtension(String) methods to allow implementations to provide more efficient ways to access single entries.

Default methods can be provided to make more efficient implementations optional:

default boolean hasExtension(String name) {
    Map<String, Object> map = getExtensions();
    if (map == null) {
        return false;
    }
    return map.containsKey(name);
}

default Object getExtension(String name) {
    Map<String, Object> map = getExtensions();
    if (map == null) {
        return null;
    }
    return map.get(name);
}
@MikeEdgar MikeEdgar added this to the MP OpenAPI 4.1 milestone Oct 18, 2024
@Azquelt Azquelt added the api label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants