Skip to content

Commit

Permalink
feat: use discriminators for ui node types in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent 2717c59 commit 59e808e
Show file tree
Hide file tree
Showing 24 changed files with 1,387 additions and 198 deletions.
11 changes: 11 additions & 0 deletions .schema/openapi/patches/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Makes uiNodeAttributes polymorph
- op: remove
path: /components/schemas/uiNodeAttributes/type
- op: add
path: /components/schemas/uiNodeAttributes/discriminator
value:
propertyName: node_type
mapping:
input: "#/components/schemas/uiNodeInputAttributes"
text: "#/components/schemas/uiNodeTextAttributes"
image: "#/components/schemas/uiNodeImageAttributes"
anchor: "#/components/schemas/uiNodeAnchorAttributes"
script: "#/components/schemas/uiNodeScriptAttributes"
- op: add
path: /components/schemas/uiNodeAttributes/oneOf
value:
- "$ref": "#/components/schemas/uiNodeInputAttributes"
- "$ref": "#/components/schemas/uiNodeTextAttributes"
- "$ref": "#/components/schemas/uiNodeImageAttributes"
- "$ref": "#/components/schemas/uiNodeAnchorAttributes"
- "$ref": "#/components/schemas/uiNodeScriptAttributes"

# Makes the uiNodeInputAttributes value attribute polymorph
- op: remove
Expand Down
6 changes: 4 additions & 2 deletions internal/httpclient/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ docs/InlineResponse200.md
docs/InlineResponse2001.md
docs/InlineResponse503.md
docs/JsonError.md
docs/Meta.md
docs/MetadataApi.md
docs/RecoveryAddress.md
docs/SelfServiceError.md
Expand Down Expand Up @@ -69,6 +68,8 @@ docs/UiNodeAnchorAttributes.md
docs/UiNodeAttributes.md
docs/UiNodeImageAttributes.md
docs/UiNodeInputAttributes.md
docs/UiNodeMeta.md
docs/UiNodeScriptAttributes.md
docs/UiNodeTextAttributes.md
docs/UiText.md
docs/V0alpha2Api.md
Expand All @@ -93,7 +94,6 @@ model_inline_response_200.go
model_inline_response_200_1.go
model_inline_response_503.go
model_json_error.go
model_meta.go
model_recovery_address.go
model_self_service_error.go
model_self_service_login_flow.go
Expand Down Expand Up @@ -139,6 +139,8 @@ model_ui_node_anchor_attributes.go
model_ui_node_attributes.go
model_ui_node_image_attributes.go
model_ui_node_input_attributes.go
model_ui_node_meta.go
model_ui_node_script_attributes.go
model_ui_node_text_attributes.go
model_ui_text.go
model_verifiable_identity_address.go
Expand Down
3 changes: 2 additions & 1 deletion internal/httpclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Class | Method | HTTP request | Description
- [InlineResponse2001](docs/InlineResponse2001.md)
- [InlineResponse503](docs/InlineResponse503.md)
- [JsonError](docs/JsonError.md)
- [Meta](docs/Meta.md)
- [RecoveryAddress](docs/RecoveryAddress.md)
- [SelfServiceError](docs/SelfServiceError.md)
- [SelfServiceLoginFlow](docs/SelfServiceLoginFlow.md)
Expand Down Expand Up @@ -187,6 +186,8 @@ Class | Method | HTTP request | Description
- [UiNodeAttributes](docs/UiNodeAttributes.md)
- [UiNodeImageAttributes](docs/UiNodeImageAttributes.md)
- [UiNodeInputAttributes](docs/UiNodeInputAttributes.md)
- [UiNodeMeta](docs/UiNodeMeta.md)
- [UiNodeScriptAttributes](docs/UiNodeScriptAttributes.md)
- [UiNodeTextAttributes](docs/UiNodeTextAttributes.md)
- [UiText](docs/UiText.md)
- [VerifiableIdentityAddress](docs/VerifiableIdentityAddress.md)
Expand Down
115 changes: 88 additions & 27 deletions internal/httpclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,7 @@ paths:
Browser flows with HTTP Header `Accept: application/json` respond with
HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success;
HTTP 302 redirect to a fresh login flow if the original flow expired with the appropriate error messages set;
HTTP 401 when the endpoint is called without a valid session cookie.
HTTP 403 when the page is accessed without a session cookie or the session's AAL is too low.
HTTP 400 on form validation errors.
Expand Down Expand Up @@ -1592,7 +1593,7 @@ paths:
was set, the browser will be redirected to the login endpoint.
If this endpoint is called via an AJAX request, the response contains the settings flow without any redirects
or a 403 forbidden error if no valid session was set.
or a 401 forbidden error if no valid session was set.
Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator
Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn
Expand Down Expand Up @@ -1622,6 +1623,12 @@ paths:
"302":
description: Empty responses are sent when, for example, resources are deleted.
The HTTP status code for empty responses is typically 201.
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/jsonError'
description: jsonError
"403":
content:
application/json:
Expand All @@ -1641,8 +1648,7 @@ paths:
get:
description: |-
When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie
or the Ory Kratos Session Token are set. The public endpoint does not return 404 status codes
but instead 403 or 500 to improve data privacy.
or the Ory Kratos Session Token are set.
Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator
Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn
Expand Down Expand Up @@ -1698,6 +1704,12 @@ paths:
schema:
$ref: '#/components/schemas/selfServiceSettingsFlow'
description: selfServiceSettingsFlow
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/jsonError'
description: jsonError
"403":
content:
application/json:
Expand Down Expand Up @@ -2104,21 +2116,6 @@ components:
title: JSONRawMessage represents a json.RawMessage that works well with JSON,
SQL, and Swagger.
type: object
Meta:
description: |-
This might include a label and other information that can optionally
be used to render UIs.
example:
label:
context: '{}'
id: 0
text: text
type: type
properties:
label:
$ref: '#/components/schemas/uiText'
title: A Node's Meta Information
type: object
RecoveryAddress:
example:
updated_at: 2000-01-23T04:56:07.000+00:00
Expand Down Expand Up @@ -4021,7 +4018,7 @@ components:
$ref: '#/components/schemas/uiText'
type: array
meta:
$ref: '#/components/schemas/Meta'
$ref: '#/components/schemas/uiNodeMeta'
type:
type: string
required:
Expand All @@ -4043,20 +4040,32 @@ components:
id:
description: A unique identifier
type: string
node_type:
type: string
title:
$ref: '#/components/schemas/uiText'
required:
- href
- id
- node_type
- title
title: AnchorAttributes represents the attributes of an anchor node.
type: object
uiNodeAttributes:
discriminator:
mapping:
anchor: '#/components/schemas/uiNodeAnchorAttributes'
image: '#/components/schemas/uiNodeImageAttributes'
input: '#/components/schemas/uiNodeInputAttributes'
script: '#/components/schemas/uiNodeScriptAttributes'
text: '#/components/schemas/uiNodeTextAttributes'
propertyName: node_type
oneOf:
- $ref: '#/components/schemas/uiNodeInputAttributes'
- $ref: '#/components/schemas/uiNodeTextAttributes'
- $ref: '#/components/schemas/uiNodeImageAttributes'
- $ref: '#/components/schemas/uiNodeAnchorAttributes'
- $ref: '#/components/schemas/uiNodeScriptAttributes'
title: Attributes represents a list of attributes (e.g. `href="foo"` for links).
uiNodeGroup:
type: string
Expand All @@ -4069,6 +4078,8 @@ components:
id:
description: A unique identifier
type: string
node_type:
type: string
src:
description: |-
The image's source URL.
Expand All @@ -4081,6 +4092,7 @@ components:
type: integer
required:
- id
- node_type
- src
title: ImageAttributes represents the attributes of an image node.
type: object
Expand All @@ -4097,19 +4109,13 @@ components:
name:
description: The input's element name.
type: string
node_type:
type: string
onclick:
description: |-
OnClick may contain javascript which should be executed on click. This is primarily
used for WebAuthn.
type: string
onload:
description: |-
OnLoad may contain javascript which should be executed on load. This is primarily
used for WebAuthn. Using this value makes most sense when used on the server-side. For
JavaScript apps running in the browser please load the WebAuthn JavaScript:
<script src="https://public-kratos.example.org/.well-known/ory/webauthn.js" type="script" async />
type: string
pattern:
description: The input's pattern.
type: string
Expand All @@ -4124,17 +4130,72 @@ components:
required:
- disabled
- name
- node_type
- type
type: object
uiNodeMeta:
description: |-
This might include a label and other information that can optionally
be used to render UIs.
example:
label:
context: '{}'
id: 0
text: text
type: type
properties:
label:
$ref: '#/components/schemas/uiText'
title: A Node's Meta Information
type: object
uiNodeScriptAttributes:
properties:
async:
description: The script async type
type: boolean
crossorigin:
description: The script cross origin policy
type: string
id:
description: A unique identifier
type: string
integrity:
description: The script's integrity hash
type: string
node_type:
type: string
referrerpolicy:
description: The script referrer policy
type: string
src:
description: The script source
type: string
type:
description: The script MIME type
type: string
required:
- async
- crossorigin
- id
- integrity
- node_type
- referrerpolicy
- src
- type
title: ScriptAttributes represent script nodes which load javascript.
type: object
uiNodeTextAttributes:
properties:
id:
description: A unique identifier
type: string
node_type:
type: string
text:
$ref: '#/components/schemas/uiText'
required:
- id
- node_type
- text
title: TextAttributes represents the attributes of a text node.
type: object
Expand Down
32 changes: 26 additions & 6 deletions internal/httpclient/api_v0alpha2.go

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

0 comments on commit 59e808e

Please sign in to comment.