Forum Discussion

inspector6's avatar
inspector6
New Contributor
7 years ago

Integration JSON Format

I recently activated the Bitbucket integration.  I'm sending my API definition to a repo in the JSON and YAML formats.  I noticed that the JSON that is output by this integration is a different format than the JSON that is produced when you download the file manually.  Specifically, any model that has a JSON object as a child param is reformatted such that the child object is broken out as a separate definition with the name [parent object]_[child object].  When I try to import this definition into the AWS API Gateway it fails b/c the name has an underscore in it.

 

I know I can download the file manually and it will be formatted appropriately but I'm trying to automate deployment so that as soon as I click the Bitbucket integration the entire deployment process is automated.

 

Any help will be much appreciated!  Thanks.

3 Replies

  • Hi,

     

    I tried the integration with BitBucket and I'm not seeing the [parent object]_[child object] issue in the file, maybe I'm overlooking something as the JSON is rather large.  Can you post the [parent object]_[child object] that is being generated in the swagger json file created in BitBucket?

     

    Regards,

    Marcus

    SmartBear Support

    • inspector6's avatar
      inspector6
      New Contributor

      The example follows.  However, I think I'm okay now.  If I proactively reformatted the YAML so that there are no objects defined within another object without using a reference to a stand-alone definition.  Doing this I can make sure that all of my definition names are compliant.    It fixed it for me; although, it is a little strange that the download button produces different JSON then the integration.  Thanks!

      For example:

       

      The following JSON:

       

      "Color": {
                 "type": "object",
                 "properties": {
                     "rgb": {
                         "type": "string",
                         "description": "Red, Green, and Blue color definition (e.g., \"R 167 / G 213 / B 0\")"
                     },
                     "w3c": {
                         "type": "object",
                         "properties": {
                             "hex": {
                                 "type": "string",
                                 "description": "(e.g., \"#696969\")"
                             },
                             "name": {
                                 "type": "string",
                                 "description": "(e.g., DimGray)"
                             }
                         }
                     },
                    }

       

      Will be reformatted as:

       

      "Color" : {
           "type" : "object",
           "properties" : {

      "rgb": {
                         "type": "string",
                         "description": "Red, Green, and Blue color definition (e.g., \"R 167 / G 213 / B 0\")"
                     },
                    "w3c" : {
               "$ref" : "#/definitions/Color_w3c"
             },

           }
         },

       

      With a reference to this newly created definition that fails the AWS API Gateway import because of the underscore:

       

      "Color_w3c" : {
           "properties" : {
             "hex" : {
               "type" : "string",
               "description" : "(e.g., \"#696969\")"
             },
             "name" : {
               "type" : "string",
               "description" : "(e.g., DimGray)"
             }
           }
         }

      • MarcusJ's avatar
        MarcusJ
        Moderator

        Thanks for the example and glad you found a workaround.  The generated JSON in BitBucket is valid, the Color_w3c is used as a reference from the w3c node instead of being a child node.  The JSON file is formatted to use JSON  references which is valid.

         

         

        "w3c" : {
                  "$ref" : "#/definitions/Color_w3c"
                },

         

        I'm not sure why the JSON is changing when it is deployed to a repo via BitBucket integration so I will open a Swaggerhub issue for that.  As far as AWS Gateway failing when using a JSON  node with an underscore in the name that sounds like an issue with AWS Gateway as I think they should allow this.

         

        Regards,

        Marcus

        SmartBear Support