Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Documentation API - Save Bug #226

Merged
merged 1 commit into from Sep 9, 2014

Conversation

weierophinney
Copy link
Member

I encounter this bug (on DB-connected service) :

The API documentation does not record, only the general description is recorded, collection entity, GET, POST, etc ... they are not recorded.
I have to write to the hands the file documentation.config.php but reading documentation its works.

If i change documentation with the admin interface, i lost the documentation, persists only the general description. This suggests to error when saving but no error in the logs files.

After looking at the source code and make some testing, the problem would be the parameter "$controllerType" in method "storeDocumentation" because "controllerType" take the value "RPC" while I save documention a "REST" service. So the method "getSchemaTemplate" does not return the correct documentation template and the method "storeDocumentation" does not correctly recorded documentation see "storeDocumentation" (array_intersect_key)

I guess the problem just webapp (js/controllers/api-documentation.js)
Afer some testing I arrive on file (js/services/api.js) on method "saveDocumentation" and two paramters :

  • Paramter 1 "url" : in my case : http://{domaine}/apigility/api/module/{API name}/rpc/{Controller Name}/doc

The problem is in url "RPC" while I work on "REST" service, if I replace "RPC" by "REST" its works, the documentation is correctly recorded but only for services "REST" because I just quickly test with : url = url.replace('rpc', 'rest');

  • Parameter 2 "api.documentation" : documentation send is clean.

I work on debian 7 - Apache 2.2.22 - PHP (mod) 5.4.4 - browser: Chrome and Iceweasel

@Gui-D Gui-D changed the title documentation API - Save Bug Documentation API - Save Bug Aug 20, 2014
@edipoReboucas
Copy link

This bug happens when I change to documentation tab, not only on db-connected services.

Maybe this is a client bug.

My workaround for now is force the #controllerType value to 'rest'.

@weierophinney
Copy link
Member

I have been unable to reproduce this -- switching between RPC and REST services, I've been able to update documentation without a problem.

js/services/api.js uses the self relational link in order to build the API service URI for updating the documentation. As such, the service type segment should not be changing; it should be static based on what the API returned for the service in the first place.

If I can reproduce this, I'll work on a fix; in the meantime, if you can reliably reproduce it, keep tracing, and find out what is being stored for the API's _self member; if that value is getting modified, figure out where, and report here.

@weierophinney
Copy link
Member

Okay, reproduced here. Trying to work on a fix.

@weierophinney
Copy link
Member

Discovered the root cause of the problem: the API is creating the documentation relational links incorrectly, and using /rpc/ instead of /rest/ within the generated URIs for REST services. I'll get this updated shortly.

weierophinney added a commit to weierophinney/zf-apigility-admin that referenced this pull request Sep 9, 2014
…names

Originally, this looked for just namespaced segments (`Rest` and `Rpc`).
However, with the changes made for 1.0.4 to remove encoded slashes from
service names, this breaks link injection, as it could not identify a
REST service by the namespace, and thus always identified services as
RPC. The change introduced will now also detect when the service name
contains dash-separated namespaces (`-Rest-`).
…names

Originally, this looked for just namespaced segments (`Rest` and `Rpc`).
However, with the changes made for 1.0.4 to remove encoded slashes from
service names, this breaks link injection, as it could not identify a
REST service by the namespace, and thus always identified services as
RPC. The change introduced will now also detect when the service name
contains dash-separated namespaces (`-Rest-`).
@weierophinney weierophinney merged commit db70c8f into zfcampus:master Sep 9, 2014
weierophinney added a commit that referenced this pull request Sep 9, 2014
weierophinney added a commit that referenced this pull request Sep 9, 2014
@weierophinney weierophinney deleted the hotfix/226 branch September 9, 2014 19:54
@weierophinney weierophinney added this to the 1.0.5 milestone Sep 9, 2014
@weierophinney
Copy link
Member

Fixed. You can test it out by changing the "zf-apigility-admin" entry in your composer.json to use the version ~1.0-dev@dev, and then running composer update.

@edipoReboucas
Copy link

Fixed. I tested with rest and rpc services.
Tks.

@jebbdomingo
Copy link

Please update Apigility documentation "Creating a REST Service" https://www.apigility.org/documentation/intro/first-rest-service, the "Documentation" section didn't work due to this bug.

Kind Regards,

@weierophinney
Copy link
Member

@jeboy There's no reason to update the documentation; this functionality worked prior to 1.0.4, and will work with the next release (or, if you're adventurous, with current master).

@edipoReboucas Thanks for the verification!

@cookejames
Copy link

Thanks for the fix, I had tracked down the problem but luckily found this bug before creating a fix. I can confirm that this is fixed for me now that I've updated to 1.0.6.

@EagleEyeJohn
Copy link

@weierophinney version ~1.0-dev@dev didn't work for me, but dev-master did fix this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants