Skip to content

Commit

Permalink
stable sort added classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jan 6, 2024
1 parent 9e6a2a3 commit bcc74f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
52 changes: 26 additions & 26 deletions examples/out.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1453,17 +1453,22 @@ capella:
$ref: '#/phase0/Root'
body:
$ref: '#/capella/BeaconBlockBody'
LightClientUpdate:
LightClientBootstrap:
type: object
properties:
attested_header:
header:
$ref: '#/capella/LightClientHeader'
next_sync_committee:
current_sync_committee:
$ref: '#/altair/SyncCommittee'
next_sync_committee_branch:
current_sync_committee_branch:
type: array
items:
$ref: '#/primitive/Bytes32'
LightClientFinalityUpdate:
type: object
properties:
attested_header:
$ref: '#/capella/LightClientHeader'
finalized_header:
$ref: '#/capella/LightClientHeader'
finality_branch:
Expand All @@ -1483,22 +1488,17 @@ capella:
$ref: '#/altair/SyncAggregate'
signature_slot:
$ref: '#/phase0/Slot'
LightClientBootstrap:
LightClientUpdate:
type: object
properties:
header:
attested_header:
$ref: '#/capella/LightClientHeader'
current_sync_committee:
next_sync_committee:
$ref: '#/altair/SyncCommittee'
current_sync_committee_branch:
next_sync_committee_branch:
type: array
items:
$ref: '#/primitive/Bytes32'
LightClientFinalityUpdate:
type: object
properties:
attested_header:
$ref: '#/capella/LightClientHeader'
finalized_header:
$ref: '#/capella/LightClientHeader'
finality_branch:
Expand Down Expand Up @@ -1917,17 +1917,22 @@ deneb:
$ref: '#/deneb/BeaconBlock'
signature:
$ref: '#/phase0/BLSSignature'
LightClientUpdate:
LightClientBootstrap:
type: object
properties:
attested_header:
header:
$ref: '#/deneb/LightClientHeader'
next_sync_committee:
current_sync_committee:
$ref: '#/altair/SyncCommittee'
next_sync_committee_branch:
current_sync_committee_branch:
type: array
items:
$ref: '#/primitive/Bytes32'
LightClientFinalityUpdate:
type: object
properties:
attested_header:
$ref: '#/deneb/LightClientHeader'
finalized_header:
$ref: '#/deneb/LightClientHeader'
finality_branch:
Expand All @@ -1947,22 +1952,17 @@ deneb:
$ref: '#/altair/SyncAggregate'
signature_slot:
$ref: '#/phase0/Slot'
LightClientBootstrap:
LightClientUpdate:
type: object
properties:
header:
attested_header:
$ref: '#/deneb/LightClientHeader'
current_sync_committee:
next_sync_committee:
$ref: '#/altair/SyncCommittee'
current_sync_committee_branch:
next_sync_committee_branch:
type: array
items:
$ref: '#/primitive/Bytes32'
LightClientFinalityUpdate:
type: object
properties:
attested_header:
$ref: '#/deneb/LightClientHeader'
finalized_header:
$ref: '#/deneb/LightClientHeader'
finality_branch:
Expand Down
5 changes: 3 additions & 2 deletions pyspec2openapi/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def parse_specs(config: Dict, config_dir: str) -> Dict:
parse_doc(doc, fork, config, out)

for mutated_class in config['mutations'][fork]:
for dependant_class in config['dependants'].get(mutated_class, set()):
dependant_classes = list(config['dependants'].get(mutated_class, set()))
dependant_classes.sort() # Ensure stable output, set may iterate in diff order each time
for dependant_class in dependant_classes:
if dependant_class not in out[fork]:
print(f"Adding spec for {fork}.{dependant_class}", file=sys.stderr)
parse_container_code_block(
Expand Down Expand Up @@ -185,7 +187,6 @@ def parse_container_code_block(code: str, fork: str, config: Dict, out: Dict):
fork, prop_type, comment, config, out
)
config['dependants'].setdefault(prop_type, set()).add(class_name)
print(fork, class_name)
out[fork][class_name] = {
'type': 'object',
'properties': properties,
Expand Down

0 comments on commit bcc74f3

Please sign in to comment.