2017-10-27 2 views
1

camel-swagger를 사용하여 서비스의 API 정의를 생성하고 있습니다. 생성 된 자신감 정의를 검색 -Camel에서 생성 된 camel specific 속성을 제거합니다.

{ 
    "swagger" : "2.0", 
    "info" : { 
    "description" : "api.description", 
    "version" : "1.0", 
    "title" : "api.title", 
    "termsOfService" : "api.termsOfService", 
    "contact" : { 
     "name" : "api.contact.name", 
     "url" : "http://api.contact.url", 
     "email" : "[email protected]" 
    }, 
    "license" : { 
     "name" : "api.license.name", 
     "url" : "http://api.license.url" 
    } 
    }, 
    "host" : "0.0.0.0:13000", 
    "basePath" : "/airportinfo-service/1.0", 
    "tags" : [ { 
    "name" : "airports" 
    } ], 
    "schemes" : [ "http" ], 
    "paths" : { 
    "/airports" : { 
     "get" : { 
     "tags" : [ "airports" ], 
     "parameters" : [ ], 
     "responses" : { 
      "200" : { 
      "description" : "Output type", 
      "schema" : { 
       "$ref" : "#/definitions/Airports" 
      } 
      } 
     }, 
     "x-camelContextId" : "airportinfo-service", 
     "x-routeId" : "getAirports" 
     } 
    }, 
    "/airports/{id}" : { 
     "get" : { 
     "tags" : [ "airports" ], 
     "parameters" : [ { 
      "name" : "id", 
      "in" : "path", 
      "description" : "", 
      "required" : true, 
      "type" : "string" 
     } ], 
     "responses" : { 
      "200" : { 
      "description" : "Output type", 
      "schema" : { 
       "$ref" : "#/definitions/Airport" 
      } 
      } 
     }, 
     "x-camelContextId" : "airportinfo-service", 
     "x-routeId" : "getAirport" 
     } 
    }, 
    "/airports/health" : { 
     "get" : { 
     "tags" : [ "airports" ], 
     "parameters" : [ ], 
     "responses" : { 
      "200" : { 
      "description" : "Output type", 
      "schema" : { 
       "type" : "string", 
       "format" : "java.lang.String" 
      } 
      } 
     }, 
     "x-camelContextId" : "airportinfo-service", 
     "x-routeId" : "health" 
     } 
    } 
    }, 
    "definitions" : { 
    "Airport" : { 
     "type" : "object", 
     "properties" : { 
     "id" : { 
      "type" : "integer", 
      "format" : "int64" 
     }, 
     "airportIataCode" : { 
      "type" : "string" 
     }, 
     "airportName" : { 
      "type" : "string" 
     }, 
     "airportStatus" : { 
      "type" : "string" 
     }, 
     "airportLatitude" : { 
      "type" : "number", 
      "format" : "double" 
     }, 
     "airportLongitude" : { 
      "type" : "number", 
      "format" : "double" 
     }, 
     "airportUrl" : { 
      "type" : "string" 
     }, 
     "cityId" : { 
      "type" : "integer", 
      "format" : "int64" 
     }, 
     "cityIataCode" : { 
      "type" : "string" 
     }, 
     "cityName" : { 
      "type" : "string" 
     }, 
     "cityLatitude" : { 
      "type" : "number", 
      "format" : "double" 
     }, 
     "cityLongitude" : { 
      "type" : "number", 
      "format" : "double" 
     }, 
     "cityStatus" : { 
      "type" : "string" 
     }, 
     "cityCategory" : { 
      "type" : "string" 
     }, 
     "countryId" : { 
      "type" : "integer", 
      "format" : "int64" 
     }, 
     "countryIataCode" : { 
      "type" : "string" 
     }, 
     "countryName" : { 
      "type" : "string" 
     }, 
     "region" : { 
      "type" : "string" 
     } 
     }, 
     "x-className" : { 
     "type" : "string", 
     "format" : "demo.service.composite.airportinfo.datatypes.Airport" 
     } 
    }, 
    "Airports" : { 
     "type" : "object", 
     "properties" : { 
     "size" : { 
      "type" : "integer", 
      "format" : "int32" 
     }, 
     "airports" : { 
      "type" : "array", 
      "items" : { 
      "$ref" : "#/definitions/Airport" 
      } 
     } 
     }, 
     "x-className" : { 
     "type" : "string", 
     "format" : "demo.service.composite.airportinfo.datatypes.Airports" 
     } 
    } 
    } 
} 

상기 API의 정의는 생성하는 코드 -

restConfiguration() 
     .component("{{server.component}}") 
      .host("{{server.host}}") 
      .port("{{server.port}}") 
      .bindingMode(RestBindingMode.json) 
      .dataFormatProperty("prettyPrint", "true") 
      .contextPath("/{{service.name}}/{{service.version}}") 
       .apiContextPath("/") 
        .apiProperty("api.title", "{{api.title}}") 
        .apiProperty("api.version", "{{service.version}}") 
        .apiProperty("api.description", "{{api.description}}") 
        .apiProperty("api.termsOfService", "{{api.termsOfService}}") 
        .apiProperty("api.contact.name", "{{api.contact.name}}") 
        .apiProperty("api.contact.email", "{{api.contact.email}}") 
        .apiProperty("api.contact.url", "{{api.contact.url}}") 
        .apiProperty("api.license.name", "{{api.license.name}}") 
        .apiProperty("api.license.url", "{{api.license.url}}") 
        .apiProperty("apiContextIdListing", "{{apiContextIdListing}}") 
        .apiProperty("apiContextIdPattern", "{{apiContextIdPattern}}"); 

    rest("/airports") 
     .get() 
     .id("getAirports") 
      .outType(Airports.class) 
      .to("direct:getAirports") 
     .get("/{id}") 
     .id("getAirport") 
      .outType(Airport.class) 
      .to("direct:getAirport") 
     .get("/health") 
     .id("health") 
      .outType(String.class) 
      .to("direct:health"); 

지금, 내가 AWS API 게이트웨이에서이 정의를 가져올를.

"x-className" : { 
    "type" : "string", 
    "format" : "demo.service.composite.airportinfo.datatypes.Airport" 
} 
  • "x-className" : { 
        "type" : "string", 
        "format" : "demo.service.composite.airportinfo.datatypes.Airports" 
    } 
    
  • 필요를 제거해야 제거 할

    1. 필요 - 그러나, 같은 때문에 위에서 주어진 API 정의에서 다음과 같은 부분으로 받아 들여지고 있지 않습니다 바꾸려면

      "schema" : { 
          "type" : "string", 
          "format" : "java.lang.String" 
      } 
      
      "schema" : { 
          "format" : "String" 
      } 
      

    이러한 변경을 만들기로

    , 나는 쉽게 AWS API 게이트웨이의 정의를 가져올 수 있어요.

    camel-swagger를 사용하여 생성 된 swagger 정의에서 Camel 특정 속성을 억제하는 방법이 있습니까?

    감사합니다.

  • 답변

    0

    아니요 항상 허용되지 않습니다.

    https://swagger.io/specification/#specificationExtensions 나는 다음 릴리스에서이에 대한 지원을 추가 할 수있는 티켓을 기록 :

    이러한 유형의 사양에 설명 된대로 그들이 x- 시작 예를 들어, 확장입니다 https://issues.apache.org/jira/browse/CAMEL-11957

    그리고 우리는 또한 원시 고정 유형을 사용하지 않으려면 응답을 입력하십시오. https://issues.apache.org/jira/browse/CAMEL-11960

    관련 문제