From bcc74f31d7722f8e2c3c0b1e43ba4c508807b093 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Sat, 6 Jan 2024 18:11:18 +0700 Subject: [PATCH] stable sort added classes --- examples/out.yml | 52 ++++++++++++++++++++--------------------- pyspec2openapi/index.py | 5 ++-- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/examples/out.yml b/examples/out.yml index 2fb85db..ce2baf5 100644 --- a/examples/out.yml +++ b/examples/out.yml @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/pyspec2openapi/index.py b/pyspec2openapi/index.py index 51e279e..a76715b 100644 --- a/pyspec2openapi/index.py +++ b/pyspec2openapi/index.py @@ -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( @@ -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,