OpenAPI docs source #441
Replies: 4 comments 12 replies
-
This link isn't autogenerated. It also isn't anywhere near complete. It was submitted by a user in #374, and looked useful, so I merged it. However, it is not official Rodauth documentation, and I cannot vouch for anything that page. |
Beta Was this translation helpful? Give feedback.
-
FYI, I'm working on a gem that will generate OpenAPI docs from the given Rodauth configuration. Last night I managed to come up with a DSL that will make it maintainable. I have some basic features already implemented, there are still a lot more to go. Here is the WIP in case you're interested – https://gist.github.com/janko/34450a52ac9afc1df7cb0b23ee9ab64f 🙂 It currently generates the following YAML: Open API docsopenapi: 3.0.1
info:
title: Rodauth
description: This lists all the endpoints provided by Rodauth features.
version: 2.36.0
externalDocs:
description: Rodauth documentation
url: https://rodauth.jeremyevans.net/documentation.html
tags:
- name: Login
externalDocs:
description: API docs
url: http://rodauth.jeremyevans.net/rdoc/files/doc/login_rdoc.html
- name: Logout
externalDocs:
description: API docs
url: http://rodauth.jeremyevans.net/rdoc/files/doc/logout_rdoc.html
- name: Create Account
externalDocs:
description: API docs
url: http://rodauth.jeremyevans.net/rdoc/files/doc/create_account_rdoc.html
- name: Verify Account
externalDocs:
description: API docs
url: http://rodauth.jeremyevans.net/rdoc/files/doc/verify_account_rdoc.html
- name: Change Password
externalDocs:
description: API docs
url: http://rodauth.jeremyevans.net/rdoc/files/doc/change_password_rdoc.html
paths:
"/login":
get:
tags:
- Login
summary: View Login page
responses:
'200':
description: Rendered login page
parameters: []
post:
tags:
- Login
summary: Perform login
responses:
'302':
description: successful login
'401':
description: no matching login, invalid password
'403':
description: unverified account
parameters:
- name: login
in: query
description: Email address for the account
required: true
style: form
example: [email protected]
schema:
type: string
- name: password
in: query
description: Password for the account
required: true
style: form
example: secret123
schema:
type: string
"/logout":
get:
tags:
- Logout
summary: View logout page
responses:
'200':
description: Rendered logout page
parameters: []
post:
tags:
- Logout
summary: Perform logout
responses:
'302':
description: successful logout
parameters: []
"/create-account":
get:
tags:
- Create Account
summary: View registration page
responses:
'200':
description: Rendered registration page
parameters: []
post:
tags:
- Create Account
summary: Perform registration
responses:
'302':
description: successful registration
'422':
description: invalid login
parameters:
- name: login
in: query
description: Email address for the account
required: true
style: form
example: [email protected]
schema:
type: string
"/verify-account":
get:
tags:
- Verify Account
summary: View email verification page
responses:
'200':
description: Rendered verification page
'302':
description: invalid verify account key
parameters:
- name: key
in: query
description: Email verification key
required: false
style: form
example: "<account_id>_<key_hmac>"
schema:
type: string
post:
tags:
- Verify Account
summary: Perform email verification
responses:
'302':
description: successful email verification, Missing or invalid token
'422':
description: invalid password, passwords do not match
parameters:
- name: key
in: query
description: Email verification token
required: false
style: form
example: "<account_id>_<key_hmac>"
schema:
type: string
- name: password
in: query
description: Password to set
required: true
style: form
example: secret123
schema:
type: string
- name: password-confirm
in: query
description: Password confirmation
required: true
style: form
example: secret123
schema:
type: string
"/verify-account-resend":
get:
tags:
- Verify Account
summary: Resend account verification email page
responses:
'200':
description: Rendered resend account verification page
parameters: []
post:
tags:
- Verify Account
summary: Perform resending account verification email
responses:
'302':
description: successful resend, email recently sent
'401':
description: no matching login
parameters:
- name: login
in: query
description: Email address for the account
required: true
style: form
example: [email protected]
schema:
type: string
"/change-password":
get:
tags:
- Change Password
summary: View change password page
responses:
'200':
description: Rendered change password page
'302':
description: Login required
parameters: []
post:
tags:
- Change Password
summary: Perform password change
responses:
'302':
description: successful password change
'401':
description: invalid previous password
'422':
description: same as existing password, invalid password, passwords do not
match
parameters:
- name: password
in: query
description: Current account password
required: true
style: form
example: oldsecret123
schema:
type: string
- name: new-password
in: query
description: Password to set
required: true
style: form
example: newsecret123
schema:
type: string
- name: password-confirm
in: query
description: Password confirmation
required: true
style: form
example: newsecret123
schema:
type: string
|
Beta Was this translation helpful? Give feedback.
-
@janko That looks interesting. How important do you think it is to have OpenAPI docs for Rodauth? Is it something you think we should include by default and all features should support? I'd be hesitant to do that, but I'm open to your suggestions. |
Beta Was this translation helpful? Give feedback.
-
A bit late to the discussion, but I think that the lack of input validation, particularly in the JSON api mode, is a gap worth filling. If rodauth routes could provide a way to declare which params a feature expects, which are required, which type, etc... it'd be possible to build a JSON schema contract, which corresponding tools could use to validate prior to route block evaluation. Openapi docs are neat, but I always find them a bit suboptimal as implementation tends to drift from it. I don't think the latter is such a big issue for the level of API stability rodauth provides, but until someone runs actual request/response payloads through them, we can't be sure they're accurate. Another point particularly for @janko 's openapi docs plugin is that it's built for "stock" rodauth, but I don't see a straightforward way for another plugin with routes (such as rodauth-oauth) to use it. |
Beta Was this translation helpful? Give feedback.
-
On the Rodauth docs, there's a link to the OpenAPI docs in postman. Since I'll be making my API available for external consumers, I'd like to add those methods to it too. I was wondering if this is auto-generated (so I could generate it along my API) or if not, if it's published along with new releases (so I have to add it manually to my docs when upgrading rodauth).
Beta Was this translation helpful? Give feedback.
All reactions