Forum Discussion

jshier's avatar
jshier
Occasional Contributor
7 years ago
Solved

Troubleshooting Mock API Generation Failure

I'm currently building an OpenAPI3 spec and trying to get the mock service to work with it. Unfortunately I'm constantly getting an integration failure from the mock API. All it says is to check the validity of the spec, which the UI says is valid. Is there any way I can troubleshoot this or get better diagnostics?

  • Thanks for sharing your spec! Please see the notes below.

     

    1) $refs need / after #:

    # wrong
    $ref: '#components/schemas/ModelName'

    # correct
    $ref: '#/components/schemas/ModelName'

     

    2) Some paths have parameters defined directly under the path rather than inside operations. While this is valid syntax, the mock currently cannot handle it. This is a known issue and the devs are working on a fix. For now, please move the parameters inside operations as a workaround.

    /v....../{id}:
    # Don't put the parameters here #parameters: # - $ref: '#/components/parameters/...' get: ...
    # Put them here for now
    parameters:
    ...

     

    Other than that, your spec looks OK.

     

    After you make the changes, either save the spec again or trigger the mock manually from the integrations list.

     

    Let me know if this helps.

7 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi jshier,

     

    Could you please post a link to your spec, so that support could have a look? Or if it's private, please share it with the swaggerhub-support user.

     

    Thanks!

    • jshier's avatar
      jshier
      Occasional Contributor

      It is private, so I've shared with swaggerhub-support.

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Thanks for sharing your spec! Please see the notes below.

         

        1) $refs need / after #:

        # wrong
        $ref: '#components/schemas/ModelName'

        # correct
        $ref: '#/components/schemas/ModelName'

         

        2) Some paths have parameters defined directly under the path rather than inside operations. While this is valid syntax, the mock currently cannot handle it. This is a known issue and the devs are working on a fix. For now, please move the parameters inside operations as a workaround.

        /v....../{id}:
        # Don't put the parameters here #parameters: # - $ref: '#/components/parameters/...' get: ...
        # Put them here for now
        parameters:
        ...

         

        Other than that, your spec looks OK.

         

        After you make the changes, either save the spec again or trigger the mock manually from the integrations list.

         

        Let me know if this helps.