question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

x-logo vendor extension

See original GitHub issue
  • [Latest] What version of the library are you using? Is it the latest version? The latest released version is Download

What kind of issue is this?

  • Question. Is this a question about how to do a certain thing?

  • [x Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

I’m trying to show custom logo in ReDoc API documentation by adding ObjectVendorExtension("x-logo") with required properties to the info section.

Expected result is:

"x-logo": {
...
}

However, the actual result is:

"extensions": {
   "x-logo": {
      ....
   }
}

How can I exclude “extensions”? Is there any workaround for this because now it is of course at variance with documentation of ReDoc?

Thank you for such a great API documentation tool.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jamesbarnett91commented, Aug 20, 2020

I’m also hitting this issue. I’ve implemented an OperationBuilderPlugin to add custom ObjectVendorExtensions and the value gets wrapped in an extensions object.

e.g. the following

@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER)
public class TestOperationBuilderPlugin implements OperationBuilderPlugin {
  
  @Override
  public void apply(OperationContext context) {
      var extension = new ObjectVendorExtension("x-test");
      context.operationBuilder().extensions(List.of(extension));
  }

  @Override
  public boolean supports(DocumentationType delimiter) {
    return SwaggerPluginSupport.pluginDoesApply(delimiter);
  }
}

produces

"extensions": {
   "x-test": {}
}

The same issue also occurs when using the the @Extension param of the @ApiOperation annotation (and probably the other applicable annotations). e.g

@ApiOperation(value = "test", extensions = {
  @Extension(properties = @ExtensionProperty(name="x-test", value="test"))
})

produces

"extensions": {
   "x-test": "test"
}

This does seem to be a bug. Consumers expect the extension properties to be directly under the parent to which they apply. Not wrapped in an extensions object. e.g https://swagger.io/specification/#specification-extensions

It looks like this only affects the OpenAPI v3 document type. The Swagger v2 type generates correctly.

I have not been able to find a workaround for OpenAPI v3 (short of post-processing the json after generation).

Thanks for looking into it. 👍

1reaction
chendongyaocommented, Jul 30, 2021

I added a JacksonModuleRegistrar to solve this problem, such as public class MyOpenApiJacksonModule extends SimpleModule implements JacksonModuleRegistrar { … @Override public void setupModule(SetupContext context) { super.setupModule(context); … context.setMixInAnnotations(Operation.class, OperationMixin.class); …

}

private interface OperationMixin {
	@JsonAnyGetter
	java.util.Map<String, Object> getExtensions();
}

}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding x-logo vendor extension using Swashbuckle Asp.Net ...
I'm using swagger.json file (generated by Swashbuckle) for ReDoc to display API documentation. What I Need: Add x-logo vendor extension to ...
Read more >
OpenAPI Extensions - Swagger
Extensions (also referred to as specification extensions or vendor extensions) are custom properties that start with x- , such as x-logo .
Read more >
Redoc vendor extensions
You can use the following vendor extensions with Redoc. Swagger Object. x-servers; x-tagGroups; Tag Group Object; x-ignoredHeaderParameters. Info Object. x-logo ...
Read more >
Can I add specification extensions to my schema? - Open API
ReDoc has a set of vendor extensions to the open api 2.0 spec. For example they have a property in the info JSON...
Read more >
xlogo - man pages section 1: User Commands
xlogo - X Window System logo. ... This option indicates that the logo should be drawn with anti- aliased edges using the RENDER...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found