Get docs/swagger JSON for single endpoint

I’m trying to get the docs for a single endpoint so I can generate a swagger client for just one of the services. Is there a way to do this? I tried /api/v2/api_docs/serviceName but it just returned the same JSON the top level did.

I’d also like to expose these docs for developers for each endpoint, rather than all of them.

Is there a way to do this?

Thanks,
Josiah

1 Like

Hey @jraiche,

Thanks for posting! However, I’m not sure I understand the question. It would help to know what service you’re talking about…a database, remote http API, something else?

Thanks,
@AlexBowen

Hey @AlexBowen, thanks for the reply. Let me see if I can make this more clear.

I’m trying to get this page:

For just this service:

My thought was that if the URL was /api/v2/api_docs, the docs for a particular service would be at /api/v2/api_docs/users, but both URLs return the full docs.

The reason we’d like this is that we can generate functional client libraries using swagger over at https://generator.swagger.io/, but most people probably won’t want all of the services in the instance, just the one they need. Manually editing the JSON is tedious. It would also be great to be able to link to the docs for just one service.

@jraiche, there is currently no way to cherry pick a swagger definition for a single service using the api/v2/api_docs API. You will need to get the full doc and then take out the piece that you need from it.

Alternatively, you can try the api/v2/system/service/ API. Replace with your service id. This will give you all the information about your service including the swagger doc inside the ‘doc.content’ section. However, the doc here is stringified. You will need to convert it to JSON before you can use it.

Hope this helps.

1 Like

@aislam, I’m not able to see the swagger info when I hit that URL - what version are you on?

Here’s the output I get:

http://localhost:81/api/v2/system/service/12?fields=*
{
  "id": 12,
  "name": "samples",
  "label": "samples",
  "description": "Sample Tables",
  "is_active": true,
  "type": "mysql",
  "mutable": true,
  "deletable": true,
  "created_date": "2016-08-26 16:21:45",
  "last_modified_date": "2016-08-26 20:21:45",
  "created_by_id": 1,
  "last_modified_by_id": 1,
  "config": {
    "service_id": 12,
    "options": null,
    "attributes": null,
    "statements": null,
    "host": "localhost",
    "port": 3300,
    "database": "################",
    "username": "################",
    "password": "################",
    "default_schema_only": true,
    "cache_enabled": false,
    "cache_ttl": 0
  }
}

What is your DreamFactory version?

Admin Application Version: 2.2.1

DreamFactory Version: 2.2.0

Sorry, The ‘doc’ section is available in version 2.3 and up. In your case you will need to use the api/v2/api_docs API.

1 Like