-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
Seems like there are still some rebase problems, travis fails... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we have to include the whole swagger code in the API?
The design looks weird as well. Can we make the resource description smaller, in a new line or bold the resource name? Currently the resource name and the description are in one block, I don't like that.
We loose a lot of documentation like max and min values and additional validators. Can we at least give something like the resource definition or a link to it?
Otherwise see the comments I left. I think some things should be changed.
amivapi/auth/sessions.py
Outdated
# 'POST': "Login and aquire a login token. Post the fields " | ||
# "'username' and 'password', the response will contain the " | ||
# "token. 'username' can be either nethz, mail, or user_id", | ||
# 'GET': "Check token(s)."} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documentation lost now? If yes, can we add it somewhere else?
If no, can we remove this comment?
amivapi/docs.py
Outdated
add_documentation({'definitions': {'User': {'properties': { | ||
'password': {'default': ''}, | ||
'nethz': {'default': ''} | ||
}}}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this? We generate empty documentation fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swagger in the currrent version does not support
Default: null
And crashes. They decided to fix this only in later versions, so for now we have to replace all null fields with something else
amivapi/docs.py
Outdated
'name': 'Authorization', | ||
'in': 'header', | ||
'description': 'enter a token you got with POST to /sessions' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is badly worded, as it suggests API keys and tokens are the same. Looking at the created website, I propose:
name: Authorization header
remove in
description: 'enter either a session token, you retrived using POST to /sessions, or an API key defined in the server config.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is swagger code. Swagger supports 3 types of authorization schemes, and they call token-based authorization 'apiKey'
'name' is the key of the header field, this cant be changes therefore.
But if course we can adapt the description field
amivapi/events/model.py
Outdated
'2014-12-20T11:50:06Z', | ||
# 'methods': { | ||
# 'GET': 'You are always allowed, even without session, ' | ||
# 'to view AMIV-Events' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: do we loose this? remove comment?
amivapi/events/model.py
Outdated
'events.', | ||
# 'methods': { | ||
# 'PATCH': 'Only additional_fields can be changed' | ||
# } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing again
amivapi/settings.py
Outdated
'termsOfService': 'todo', | ||
'contact': { | ||
'name': 'AMIV an der ETH', | ||
'url': 'http://amiv.ch/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https please
amivapi/settings.py
Outdated
'title': 'AMIVAPI', | ||
'version': '0.1-dev', | ||
'description': "The REST API behind most of AMIV's web services.", | ||
'termsOfService': 'todo', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a # TODO comment, so this shows up in grep
amivapi/settings.py
Outdated
'url': 'http://amiv.ch/' | ||
}, | ||
'license': { | ||
'name': 'GNU', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just puts "GNU" without context to the website. We need to write what it is.
Change to "GNU Affero General Public License"?
'add_permitted_methods_after_fetch_item', | ||
'add_permitted_methods_after_fetch_resource', | ||
'add_permitted_methods_for_home', | ||
'add_permitted_methods_after_update'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to work. add_permitted_methods_after_insert is shown under POST to joboffers.
Any ideas?
amivapi/settings.py
Outdated
'add_permitted_methods_after_fetch_resource', | ||
'add_permitted_methods_for_home', | ||
'add_permitted_methods_after_update'] | ||
X_DOMAINS = ['http://127.0.0.1:5000', # The domain where Swagger UI is running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This IP should not be hardcoded, this breaks the documentation in many setups. The address should be available via flask. (maybe SERVER_NAME config value?)
I fixed all the comments I made apart from the one about the code in docs.py line 50. It is not clear to me, what that code is for. Still design does not look good and we are missing the validator information. |
Looking at other swagger based documentation, I think we should move the description of resources to implementation_notes and just have a short string for the description. |
I fixed the authorization again following my comments above |
I think the documentation with realtion to special HTTP methods is OK now, even though it should in the end only be displayed for the actual method you look at right now. Also related to the more detailed description and "summary": How do you suggest to structure the json? We could think of something like this:
We would then adapt the mapping into the swagger fields, this is done by eve-swagger and therefore easily adaptable as we already use our own fork |
I like that approach. |
For the documentation of validation rules: This is a known swagger issue right now. It looks like they lost this with the implementation of the example objects as they had it before. Apparently you can see some stuff by hovering, but I do not consider this a solution. As we can expect this issue to be worked on, I suggest an easy solution for the moment printing out the schema into the implementation notes via our version of eve-swagger. |
Doing some more research 😃 I think I actually prefer this much more over swagger: http://rebilly.github.io/ReDoc/ What are your opinions? |
I have at least two issues:
An easy solution to 2 might be to have: amivapi/documentation/lib/swagger_ui/ |
You fixed the import error by yourself, thanks and sorry for that 🤙 Concerning the structure: This was actually only there as I never really got a feedback whether we should use ReDoc or SwaggerUI. As nobody seems to care too much, I simply decided for ReDoc, which we can include as external JS and therefore we only need the file |
Fancy new swagger interface for /docs added by hermann