Skip to content

Commit

Permalink
fix: openapi regression (#2465)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrik <zepatrik@users.noreply.github.com>
  • Loading branch information
aeneasr and zepatrik committed May 13, 2022
1 parent 27336b6 commit 37a3369
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 130 deletions.
30 changes: 0 additions & 30 deletions internal/httpclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5124,12 +5124,6 @@ components:
description: |-
NodeType represents this node's types. It is a mirror of `node.type` and
is primarily used to allow compatibility with OpenAPI 3.0.
enum:
- text
- input
- img
- a
- script
type: string
title:
$ref: '#/components/schemas/uiText'
Expand Down Expand Up @@ -5169,12 +5163,6 @@ components:
description: |-
NodeType represents this node's types. It is a mirror of `node.type` and
is primarily used to allow compatibility with OpenAPI 3.0.
enum:
- text
- input
- img
- a
- script
type: string
src:
description: |-
Expand Down Expand Up @@ -5211,12 +5199,6 @@ components:
description: |-
NodeType represents this node's types. It is a mirror of `node.type` and
is primarily used to allow compatibility with OpenAPI 3.0.
enum:
- text
- input
- img
- a
- script
type: string
onclick:
description: |-
Expand Down Expand Up @@ -5273,12 +5255,6 @@ components:
description: |-
NodeType represents this node's types. It is a mirror of `node.type` and
is primarily used to allow compatibility with OpenAPI 3.0.
enum:
- text
- input
- img
- a
- script
type: string
nonce:
description: |-
Expand Down Expand Up @@ -5318,12 +5294,6 @@ components:
description: |-
NodeType represents this node's types. It is a mirror of `node.type` and
is primarily used to allow compatibility with OpenAPI 3.0.
enum:
- text
- input
- img
- a
- script
type: string
text:
$ref: '#/components/schemas/uiText'
Expand Down
35 changes: 0 additions & 35 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1899,13 +1899,6 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"enum": [
"text",
"input",
"img",
"a",
"script"
],
"type": "string"
},
"title": {
Expand Down Expand Up @@ -1964,13 +1957,6 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"enum": [
"text",
"input",
"img",
"a",
"script"
],
"type": "string"
},
"src": {
Expand Down Expand Up @@ -2012,13 +1998,6 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"enum": [
"text",
"input",
"img",
"a",
"script"
],
"type": "string"
},
"onclick": {
Expand Down Expand Up @@ -2079,13 +2058,6 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"enum": [
"text",
"input",
"img",
"a",
"script"
],
"type": "string"
},
"nonce": {
Expand Down Expand Up @@ -2127,13 +2099,6 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"enum": [
"text",
"input",
"img",
"a",
"script"
],
"type": "string"
},
"text": {
Expand Down
45 changes: 5 additions & 40 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4111,14 +4111,7 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"type": "string",
"enum": [
"text",
"input",
"img",
"a",
"script"
]
"type": "string"
},
"title": {
"$ref": "#/definitions/uiText"
Expand Down Expand Up @@ -4151,14 +4144,7 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"type": "string",
"enum": [
"text",
"input",
"img",
"a",
"script"
]
"type": "string"
},
"src": {
"description": "The image's source URL.\n\nformat: uri",
Expand Down Expand Up @@ -4197,14 +4183,7 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"type": "string",
"enum": [
"text",
"input",
"img",
"a",
"script"
]
"type": "string"
},
"onclick": {
"description": "OnClick may contain javascript which should be executed on click. This is primarily\nused for WebAuthn.",
Expand Down Expand Up @@ -4270,14 +4249,7 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"type": "string",
"enum": [
"text",
"input",
"img",
"a",
"script"
]
"type": "string"
},
"nonce": {
"description": "Nonce for CSP\n\nA nonce you may want to use to improve your Content Security Policy.\nYou do not have to use this value but if you want to improve your CSP\npolicies you may use it. You can also choose to use your own nonce value!",
Expand Down Expand Up @@ -4312,14 +4284,7 @@
},
"node_type": {
"description": "NodeType represents this node's types. It is a mirror of `node.type` and\nis primarily used to allow compatibility with OpenAPI 3.0.",
"type": "string",
"enum": [
"text",
"input",
"img",
"a",
"script"
]
"type": "string"
},
"text": {
"$ref": "#/definitions/uiText"
Expand Down
30 changes: 15 additions & 15 deletions ui/node/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ type InputAttributes struct {
OnClick string `json:"onclick,omitempty"`

// NodeType represents this node's types. It is a mirror of `node.type` and
// is primarily used to allow compatibility with OpenAPI 3.0.
// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "input".
//
// required: true
NodeType UiNodeType `json:"node_type"`
NodeType string `json:"node_type"`
}

// ImageAttributes represents the attributes of an image node.
Expand Down Expand Up @@ -107,10 +107,10 @@ type ImageAttributes struct {
Height int `json:"height"`

// NodeType represents this node's types. It is a mirror of `node.type` and
// is primarily used to allow compatibility with OpenAPI 3.0.
// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "img".
//
// required: true
NodeType UiNodeType `json:"node_type"`
NodeType string `json:"node_type"`
}

// AnchorAttributes represents the attributes of an anchor node.
Expand All @@ -134,10 +134,10 @@ type AnchorAttributes struct {
Identifier string `json:"id"`

// NodeType represents this node's types. It is a mirror of `node.type` and
// is primarily used to allow compatibility with OpenAPI 3.0.
// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "a".
//
// required: true
NodeType UiNodeType `json:"node_type"`
NodeType string `json:"node_type"`
}

// TextAttributes represents the attributes of a text node.
Expand All @@ -156,10 +156,10 @@ type TextAttributes struct {
Identifier string `json:"id"`

// NodeType represents this node's types. It is a mirror of `node.type` and
// is primarily used to allow compatibility with OpenAPI 3.0.
// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "text".
//
// required: true
NodeType UiNodeType `json:"node_type"`
NodeType string `json:"node_type"`
}

// ScriptAttributes represent script nodes which load javascript.
Expand Down Expand Up @@ -211,10 +211,10 @@ type ScriptAttributes struct {
Nonce string `json:"nonce"`

// NodeType represents this node's types. It is a mirror of `node.type` and
// is primarily used to allow compatibility with OpenAPI 3.0.
// is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is "script".
//
// required: true
NodeType UiNodeType `json:"node_type"`
NodeType string `json:"node_type"`
}

var (
Expand Down Expand Up @@ -302,21 +302,21 @@ func (a *ScriptAttributes) Reset() {
}

func (a *InputAttributes) GetNodeType() UiNodeType {
return a.NodeType
return UiNodeType(a.NodeType)
}

func (a *ImageAttributes) GetNodeType() UiNodeType {
return a.NodeType
return UiNodeType(a.NodeType)
}

func (a *AnchorAttributes) GetNodeType() UiNodeType {
return a.NodeType
return UiNodeType(a.NodeType)
}

func (a *TextAttributes) GetNodeType() UiNodeType {
return a.NodeType
return UiNodeType(a.NodeType)
}

func (a *ScriptAttributes) GetNodeType() UiNodeType {
return a.NodeType
return UiNodeType(a.NodeType)
}
20 changes: 10 additions & 10 deletions ui/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,23 +353,23 @@ func (n *Node) UnmarshalJSON(data []byte) error {
switch t := gjson.GetBytes(data, "type").String(); UiNodeType(t) {
case Text:
attr = &TextAttributes{
NodeType: Text,
NodeType: string(Text),
}
case Input:
attr = &InputAttributes{
NodeType: Input,
NodeType: string(Input),
}
case Anchor:
attr = &AnchorAttributes{
NodeType: Anchor,
NodeType: string(Anchor),
}
case Image:
attr = &ImageAttributes{
NodeType: Image,
NodeType: string(Image),
}
case Script:
attr = &ScriptAttributes{
NodeType: Script,
NodeType: string(Script),
}
default:
return fmt.Errorf("unexpected node type: %s", t)
Expand All @@ -396,19 +396,19 @@ func (n *Node) MarshalJSON() ([]byte, error) {
switch attr := n.Attributes.(type) {
case *TextAttributes:
t = Text
attr.NodeType = Text
attr.NodeType = string(Text)
case *InputAttributes:
t = Input
attr.NodeType = Input
attr.NodeType = string(Input)
case *AnchorAttributes:
t = Anchor
attr.NodeType = Anchor
attr.NodeType = string(Anchor)
case *ImageAttributes:
t = Image
attr.NodeType = Image
attr.NodeType = string(Image)
case *ScriptAttributes:
t = Script
attr.NodeType = Script
attr.NodeType = string(Script)
default:
return nil, errors.WithStack(fmt.Errorf("unknown node type: %T", n.Attributes))
}
Expand Down

0 comments on commit 37a3369

Please sign in to comment.