You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mikhail Lukyanov <lu...@gmail.com> on 2020/03/13 07:30:07 UTC

camel-swagger-java Semantic error. Methods in rest service with id have the same operationId

In camel-swagger-java, for this service

<rest id="4f777f7b-f2fd-4107-8271-a50640d4525c"  path="/path"
produces="application/json">
    <get id="026ea872-e2f8-4772-8d10-6482b8549f11"
        produces="application/json" uri="/get">
        <description/>
        <responseMessage message="OK" code="200" />
        <to uri="direct-vm://restLink"/>
    </get>
    <get id="247f814f-5970-4cc1-975d-374195ff9b42"
        produces="application/json" uri="/get2">
        <description/>
        <responseMessage message="OK" code="200" />
        <to uri="direct-vm://restLink"/>
    </get>
</rest>

I get next swagger.json, which does not pass validation because
Semantic error at paths./path/get2.get.operationIdOperations must have
unique operationIds.

{
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0",
    "title" : "REST API"
  },
  "host" : "0.0.0.0:9090",
  "basePath" : "/fesb-rest",
  "tags" : [ {
    "name" : "path"
  } ],
  "schemes" : [ "http", "https" ],
  "paths" : {
    "/path/get" : {
      "get" : {
        "tags" : [ "path" ],
        "summary" : "",
        "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
        "produces" : [ "application/json" ],
        "responses" : {
          "200" : {
            "description" : "OK"
          }
        }
      }
    },
    "/path/get2" : {
      "get" : {
        "tags" : [ "path" ],
        "summary" : "",
        "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
        "produces" : [ "application/json" ],
        "responses" : {
          "200" : {
            "description" : "OK"
          }
        }
      }
    }
  }
}

I need the id of the methods and not the service to be used, while the
service id should remain

I looked at the code and found the following in the class *RestSwaggerReader.*

String operationId = (String)Optional.ofNullable(rest.getId()).orElse(routeId);
op.operationId(operationId);

Why is the service id, and not the method, used in the first place, does
this cause a validation error if the service has several methods?
-- 
*With best regards, Lukyanov Mikhail*
*Моб: **+7-909-69-71-547*

Re: camel-swagger-java Semantic error. Methods in rest service with id have the same operationId

Posted by Mikhail Lukyanov <lu...@gmail.com>.
Camel version *3.2.0*

пт, 13 мар. 2020 г. в 10:30, Mikhail Lukyanov <lu...@gmail.com>:

> In camel-swagger-java, for this service
>
> <rest id="4f777f7b-f2fd-4107-8271-a50640d4525c"  path="/path" produces="application/json">
>     <get id="026ea872-e2f8-4772-8d10-6482b8549f11"
>         produces="application/json" uri="/get">
>         <description/>
>         <responseMessage message="OK" code="200" />
>         <to uri="direct-vm://restLink"/>
>     </get>
>     <get id="247f814f-5970-4cc1-975d-374195ff9b42"
>         produces="application/json" uri="/get2">
>         <description/>
>         <responseMessage message="OK" code="200" />
>         <to uri="direct-vm://restLink"/>
>     </get>
> </rest>
>
> I get next swagger.json, which does not pass validation because
> Semantic error at paths./path/get2.get.operationIdOperations must have
> unique operationIds.
>
> {
>   "swagger" : "2.0",
>   "info" : {
>     "version" : "1.0",
>     "title" : "REST API"
>   },
>   "host" : "0.0.0.0:9090",
>   "basePath" : "/fesb-rest",
>   "tags" : [ {
>     "name" : "path"
>   } ],
>   "schemes" : [ "http", "https" ],
>   "paths" : {
>     "/path/get" : {
>       "get" : {
>         "tags" : [ "path" ],
>         "summary" : "",
>         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
>         "produces" : [ "application/json" ],
>         "responses" : {
>           "200" : {
>             "description" : "OK"
>           }
>         }
>       }
>     },
>     "/path/get2" : {
>       "get" : {
>         "tags" : [ "path" ],
>         "summary" : "",
>         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
>         "produces" : [ "application/json" ],
>         "responses" : {
>           "200" : {
>             "description" : "OK"
>           }
>         }
>       }
>     }
>   }
> }
>
> I need the id of the methods and not the service to be used, while the service id should remain
>
> I looked at the code and found the following in the class *RestSwaggerReader.*
>
> String operationId = (String)Optional.ofNullable(rest.getId()).orElse(routeId);
> op.operationId(operationId);
>
> Why is the service id, and not the method, used in the first place, does
> this cause a validation error if the service has several methods?
> --
> *With best regards, Lukyanov Mikhail*
> *Моб: **+7-909-69-71-547*
>


-- 
*С наилучшими пожеланиями, Лукьянов Михаил*
*Моб: **+7-909-69-71-547​*

Re: camel-swagger-java Semantic error. Methods in rest service with id have the same operationId

Posted by Mikhail Lukyanov <lu...@gmail.com>.
Ok, understand, i'll do it

пт, 13 мар. 2020 г., 11:36 Claus Ibsen <cl...@gmail.com>:

> Hi
>
> Yeah that seems like a little bug/issue. You are welcome to create a
> JIRA ticket and work on a fix and provide it as a github PR.
>
> On Fri, Mar 13, 2020 at 8:30 AM Mikhail Lukyanov <lu...@gmail.com>
> wrote:
> >
> > In camel-swagger-java, for this service
> >
> > <rest id="4f777f7b-f2fd-4107-8271-a50640d4525c"  path="/path"
> > produces="application/json">
> >     <get id="026ea872-e2f8-4772-8d10-6482b8549f11"
> >         produces="application/json" uri="/get">
> >         <description/>
> >         <responseMessage message="OK" code="200" />
> >         <to uri="direct-vm://restLink"/>
> >     </get>
> >     <get id="247f814f-5970-4cc1-975d-374195ff9b42"
> >         produces="application/json" uri="/get2">
> >         <description/>
> >         <responseMessage message="OK" code="200" />
> >         <to uri="direct-vm://restLink"/>
> >     </get>
> > </rest>
> >
> > I get next swagger.json, which does not pass validation because
> > Semantic error at paths./path/get2.get.operationIdOperations must have
> > unique operationIds.
> >
> > {
> >   "swagger" : "2.0",
> >   "info" : {
> >     "version" : "1.0",
> >     "title" : "REST API"
> >   },
> >   "host" : "0.0.0.0:9090",
> >   "basePath" : "/fesb-rest",
> >   "tags" : [ {
> >     "name" : "path"
> >   } ],
> >   "schemes" : [ "http", "https" ],
> >   "paths" : {
> >     "/path/get" : {
> >       "get" : {
> >         "tags" : [ "path" ],
> >         "summary" : "",
> >         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
> >         "produces" : [ "application/json" ],
> >         "responses" : {
> >           "200" : {
> >             "description" : "OK"
> >           }
> >         }
> >       }
> >     },
> >     "/path/get2" : {
> >       "get" : {
> >         "tags" : [ "path" ],
> >         "summary" : "",
> >         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
> >         "produces" : [ "application/json" ],
> >         "responses" : {
> >           "200" : {
> >             "description" : "OK"
> >           }
> >         }
> >       }
> >     }
> >   }
> > }
> >
> > I need the id of the methods and not the service to be used, while the
> > service id should remain
> >
> > I looked at the code and found the following in the class
> *RestSwaggerReader.*
> >
> > String operationId =
> (String)Optional.ofNullable(rest.getId()).orElse(routeId);
> > op.operationId(operationId);
> >
> > Why is the service id, and not the method, used in the first place, does
> > this cause a validation error if the service has several methods?
> > --
> > *With best regards, Lukyanov Mikhail*
> > *Моб: **+7-909-69-71-547*
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: camel-swagger-java Semantic error. Methods in rest service with id have the same operationId

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah that seems like a little bug/issue. You are welcome to create a
JIRA ticket and work on a fix and provide it as a github PR.

On Fri, Mar 13, 2020 at 8:30 AM Mikhail Lukyanov <lu...@gmail.com> wrote:
>
> In camel-swagger-java, for this service
>
> <rest id="4f777f7b-f2fd-4107-8271-a50640d4525c"  path="/path"
> produces="application/json">
>     <get id="026ea872-e2f8-4772-8d10-6482b8549f11"
>         produces="application/json" uri="/get">
>         <description/>
>         <responseMessage message="OK" code="200" />
>         <to uri="direct-vm://restLink"/>
>     </get>
>     <get id="247f814f-5970-4cc1-975d-374195ff9b42"
>         produces="application/json" uri="/get2">
>         <description/>
>         <responseMessage message="OK" code="200" />
>         <to uri="direct-vm://restLink"/>
>     </get>
> </rest>
>
> I get next swagger.json, which does not pass validation because
> Semantic error at paths./path/get2.get.operationIdOperations must have
> unique operationIds.
>
> {
>   "swagger" : "2.0",
>   "info" : {
>     "version" : "1.0",
>     "title" : "REST API"
>   },
>   "host" : "0.0.0.0:9090",
>   "basePath" : "/fesb-rest",
>   "tags" : [ {
>     "name" : "path"
>   } ],
>   "schemes" : [ "http", "https" ],
>   "paths" : {
>     "/path/get" : {
>       "get" : {
>         "tags" : [ "path" ],
>         "summary" : "",
>         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
>         "produces" : [ "application/json" ],
>         "responses" : {
>           "200" : {
>             "description" : "OK"
>           }
>         }
>       }
>     },
>     "/path/get2" : {
>       "get" : {
>         "tags" : [ "path" ],
>         "summary" : "",
>         "operationId" : "4f777f7b-f2fd-4107-8271-a50640d4525c",
>         "produces" : [ "application/json" ],
>         "responses" : {
>           "200" : {
>             "description" : "OK"
>           }
>         }
>       }
>     }
>   }
> }
>
> I need the id of the methods and not the service to be used, while the
> service id should remain
>
> I looked at the code and found the following in the class *RestSwaggerReader.*
>
> String operationId = (String)Optional.ofNullable(rest.getId()).orElse(routeId);
> op.operationId(operationId);
>
> Why is the service id, and not the method, used in the first place, does
> this cause a validation error if the service has several methods?
> --
> *With best regards, Lukyanov Mikhail*
> *Моб: **+7-909-69-71-547*



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2