-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
ExtensionProperty missing in JSON #1523
Comments
Hi - I can't see any immediate reason to why this would fail - can you share the entire resource class to give some more context? |
i've pushed some related fixes to https://github.com/swagger-api/swagger-core/tree/issue-1523 - although I would be surprised if they helped in your specific case - if you have the time to try that would of course still be helpful :-) |
I have made a small example: package com.telenor.no.service.helloworld.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Produces("application/json")
@Path("/rest")
@Api("hello-world-v1")
@SwaggerDefinition(info =
@Info(title = "hello-world",
version = "v1",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "accessLevel", value = "private"),
})}))
public class HelloWorldServiceRest {
public HelloWorldServiceRest() {
}
@GET
@Path("/test/")
@ApiOperation(value = "Test",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "externalPath", value = "/hello-world/v1/")
})})
public Response getGreeting() {
return Response.ok("Test").build();
}
} This produces this JSON: {
"swagger": "2.0",
"info": {
"version": "Swagger Server",
"title": "",
"x-accessLevel": "private"
},
"tags": [
{
"name": "hello-world-v1"
}
],
"schemes": [
"http"
],
"paths": {
"/rest/test": {
"get": {
"tags": [
"hello-world-v1"
],
"summary": "Test",
"description": "",
"operationId": "getGreeting",
"produces": [
"application/json"
],
"parameters": [],
"responses": {
"default": {
"description": "successful operation"
}
}
}
}
}
} The x-accessLevel field is present, but the x-externalPath field is missing. |
awesome - thank you - digging in! |
so - unfortunately this works for me - how exactly are you hosting the resource? (framework, etc) |
We are running embedded Jetty (version 9.2.10.v20150310) with Jersey 2.22.1 and Jackson 2.6.3. I could try to do some debugging, but I am not familiar with the swagger-jaxrs code, could you give me some hints for where in the code I should start looking? Where to set breakpoints? |
sure - https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java#L336 is where the ApiOperation extensions should be picked up when scanning your jaxrs resource - try putting one there to see if you hit it when generating the swagger definition thanks for your help! |
I think I have found the problem. I have a filter defined, and the operation is cloned before the filter is executed. The vendorExtensions are not copied during this clone. |
awesome - let me fix that right away... can you give the branch a try afterwards? |
I have to leave now, but I can do that tomorrow. |
ok great - the fix is in https://github.com/swagger-api/swagger-core/tree/issue-1523 |
It's working fine now :-) |
awesome - thanks for confirming - i'll submit a PR for this |
Fixed in #1529. |
The ExtensionProperty is missing in JSON when placed inside the ApiOperation tag.
Example:
I would expect to find "x-externalPath": "/hello-world/v1/{endUserId}" in the JSON file, but it is missing.
This has been tested with version 1.5.4 of swagger-jersey2-jaxrs.
Note: It works fine for ExtensionProperty placed in
@SwaggerDefinition@Info
.The text was updated successfully, but these errors were encountered: