Skip to content

Commit

Permalink
fix(swagger): Use correct annotations for request methods
Browse files Browse the repository at this point in the history
Closes #234
  • Loading branch information
aeneasr committed Feb 7, 2020
1 parent d8d8bba commit 2747229
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 86 deletions.
132 changes: 101 additions & 31 deletions docs/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@
"type": "object",
"required": [
"id",
"traits_schema_id",
"traits"
],
"properties": {
Expand Down Expand Up @@ -792,6 +793,11 @@
"form": {
"description": "HTMLForm represents a HTML Form. The container can work with both HTTP Form and JSON requests",
"type": "object",
"required": [
"action",
"method",
"fields"
],
"properties": {
"action": {
"description": "Action should be used as the form action URL (\u003cform action=\"{{ .Action }}\" method=\"post\"\u003e).",
Expand All @@ -816,10 +822,15 @@
"formField": {
"description": "Field represents a HTML Form Field",
"type": "object",
"required": [
"name",
"type",
"required"
],
"properties": {
"disabled": {
"description": "Disabled is the equivalent of \u003cinput disabled=\"{{.Disabled}}\"\u003e",
"type": "string"
"type": "boolean"
},
"errors": {
"description": "Errors contains all validation errors this particular field has caused.",
Expand Down Expand Up @@ -928,6 +939,13 @@
},
"loginRequest": {
"type": "object",
"required": [
"id",
"expires_at",
"issued_at",
"request_url",
"methods"
],
"properties": {
"active": {
"$ref": "#/definitions/CredentialsType"
Expand Down Expand Up @@ -960,6 +978,10 @@
},
"loginRequestMethod": {
"type": "object",
"required": [
"method",
"config"
],
"properties": {
"config": {
"$ref": "#/definitions/loginRequestMethodConfig"
Expand All @@ -971,28 +993,52 @@
},
"loginRequestMethodConfig": {
"type": "object",
"allOf": [
{
"type": "object"
"required": [
"action",
"method",
"fields"
],
"properties": {
"action": {
"description": "Action should be used as the form action URL (\u003cform action=\"{{ .Action }}\" method=\"post\"\u003e).",
"type": "string"
},
{
"type": "object"
"errors": {
"description": "Errors contains all form errors. These will be duplicates of the individual field errors.",
"type": "array",
"items": {
"$ref": "#/definitions/Error"
}
},
{
"type": "object"
"fields": {
"$ref": "#/definitions/formFields"
},
{
"type": "object"
"method": {
"description": "Method is the form method (e.g. POST)",
"type": "string"
},
{
"type": "object"
"providers": {
"description": "Providers is set for the \"oidc\" request method.",
"type": "array",
"items": {
"$ref": "#/definitions/formField"
}
}
]
}
},
"profileManagementRequest": {
"description": "This request is used when an identity wants to update profile information\n(especially traits) in a selfservice manner.\n\nFor more information head over to: https://www.ory.sh/docs/kratos/selfservice/profile",
"type": "object",
"title": "Request presents a profile management request",
"required": [
"id",
"expires_at",
"issued_at",
"request_url",
"form",
"identity",
"update_successful"
],
"properties": {
"expires_at": {
"description": "ExpiresAt is the time (UTC) when the request expires. If the user still wishes to update the profile,\na new request has to be initiated.",
Expand Down Expand Up @@ -1025,6 +1071,14 @@
},
"registrationRequest": {
"type": "object",
"required": [
"id",
"expires_at",
"issued_at",
"request_url",
"active",
"methods"
],
"properties": {
"active": {
"$ref": "#/definitions/CredentialsType"
Expand Down Expand Up @@ -1068,32 +1122,48 @@
},
"registrationRequestMethodConfig": {
"type": "object",
"allOf": [
{
"type": "object"
},
{
"type": "object"
},
{
"type": "object"
"required": [
"action",
"method",
"fields"
],
"properties": {
"action": {
"description": "Action should be used as the form action URL (\u003cform action=\"{{ .Action }}\" method=\"post\"\u003e).",
"type": "string"
},
{
"type": "object"
"errors": {
"description": "Errors contains all form errors. These will be duplicates of the individual field errors.",
"type": "array",
"items": {
"$ref": "#/definitions/Error"
}
},
{
"type": "object"
"fields": {
"$ref": "#/definitions/formFields"
},
{
"type": "object"
"method": {
"description": "Method is the form method (e.g. POST)",
"type": "string"
},
{
"type": "object"
"providers": {
"description": "Providers is set for the \"oidc\" request method.",
"type": "array",
"items": {
"$ref": "#/definitions/formField"
}
}
]
}
},
"session": {
"type": "object",
"required": [
"sid",
"expires_at",
"authenticated_at",
"issued_at",
"identity"
],
"properties": {
"authenticated_at": {
"type": "string",
Expand Down
2 changes: 2 additions & 0 deletions identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type (
Credentials map[CredentialsType]Credentials `json:"-" faker:"-" db:"-"`

// TraitsSchemaID is the ID of the JSON Schema to be used for validating the identity's traits.
//
// required: true
TraitsSchemaID string `json:"traits_schema_id" faker:"-" db:"traits_schema_id"`

// TraitsSchemaURL is the URL of the endpoint where the identity's traits schema can be fetched from.
Expand Down
44 changes: 27 additions & 17 deletions internal/httpclient/models/login_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions internal/httpclient/models/login_request_method.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions selfservice/flow/login/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,25 @@ import (
type Request struct {
// ID represents the request's unique ID. When performing the login flow, this
// represents the id in the login ui's query parameter: http://<urls.login_ui>/?request=<id>
//
// required: true
ID uuid.UUID `json:"id" faker:"uuid" rw:"r" db:"id"`

// ExpiresAt is the time (UTC) when the request expires. If the user still wishes to log in,
// a new request has to be initiated.
//
// required: true
ExpiresAt time.Time `json:"expires_at" faker:"time_type" db:"expires_at"`

// IssuedAt is the time (UTC) when the request occurred.
//
// required: true
IssuedAt time.Time `json:"issued_at" faker:"time_type" db:"issued_at"`

// RequestURL is the initial URL that was requested from ORY Kratos. It can be used
// to forward information contained in the URL's path or query for example.
//
// required: true
RequestURL string `json:"request_url" db:"request_url"`

// Active, if set, contains the login method that is being used. It is initially
Expand All @@ -38,6 +46,8 @@ type Request struct {

// Methods contains context for all enabled login methods. If a login request has been
// processed, but for example the password is incorrect, this will contain error messages.
//
// required: true
Methods map[identity.CredentialsType]*RequestMethod `json:"methods" faker:"login_request_methods" db:"-"`

// MethodsRaw is a helper struct field for gobuffalo.pop.
Expand Down
Loading

0 comments on commit 2747229

Please sign in to comment.