Skip to content

Commit

Permalink
Merge pull request #60 from ethdebug/schema-titles
Browse files Browse the repository at this point in the history
Improve schema consistency
  • Loading branch information
gnidan authored Jan 7, 2024
2 parents 042df35 + a1baa43 commit 8632475
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
1 change: 1 addition & 0 deletions schemas/type/complex/mapping.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties:
const: mapping
contains:
type: object
title: Mapping key/value types
properties:
key:
$ref: "schema:ethdebug/format/type/wrapper"
Expand Down
4 changes: 2 additions & 2 deletions schemas/type/complex/struct.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ $defs:
**ethdebug/format/type/wrapper** with additional fields.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- type: object
title: Additional fields
- title: Additional fields
description:
An object with optional `name` property for identifying named struct
member fields. **Note** that this language does not specify that a
struct must be consistent in its use of naming for all fields or none
type: object
properties:
name:
type: string
36 changes: 23 additions & 13 deletions schemas/type/complex/tuple.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,7 @@ properties:
contains:
type: array
items:
title: '{ name?, type }'
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- properties:
name:
type: string
description:
For tuple types where positional element types are identified
by name, this field **should** include this information.

This schema makes no restriction on whether all-or-no elements
have names, and so this field may be sparse across elements of
the same tuple.
$ref: "#/$defs/Element"

required:
- kind
Expand All @@ -49,3 +37,25 @@ examples:
type:
kind: uint
bits: 128

$defs:
Element:
type: object
title: Element
description:
An optionally named element type within a tuple. This is an
**ethdebug/format/type/wrapper** with additional fields.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- title: Additional fields
type: object
properties:
name:
type: string
description:
For tuple types where positional element types are identified
by name, this field **should** include this information.

This schema makes no restriction on whether all-or-no elements
have names, and so this field may be sparse across elements of
the same tuple.
9 changes: 6 additions & 3 deletions schemas/type/elementary/contract.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ properties:
$ref: "schema:ethdebug/format/type/definition"

oneOf:
- properties:
- title: Normal contract type
properties:
library:
const: false
interface:
const: false

- properties:
- title: Contract library type
properties:
library:
const: true
description:
Indicates that this is a type representing a library
required:
- library

- properties:
- title: Contract interface type
properties:
interface:
const: true
description:
Expand Down
6 changes: 3 additions & 3 deletions web/spec/type/concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ possibly includes other fields alongside `"type"`.
{
"kind": "struct",
"contains": [{
"member": "balance",
"name": "balance",
"type": {
"kind": "uint",
"bits": 256
}
}, {
"member": "scoreSheet",
"name": "scoreSheet",
"type": {
"id": "<some opaque ID for some `ScoreSheet` type>"
}
Expand All @@ -127,7 +127,7 @@ possibly includes other fields alongside `"type"`.
```

In this example, please note how this struct type represents member names
with a `"member"` field alongside the `"type"` field, and note how the
with a `"name"` field alongside the `"type"` field, and note how the
value of `"type"` can be either a complete representation or a reference
object in the form of `{ id }`.
</TabItem>
Expand Down

0 comments on commit 8632475

Please sign in to comment.