Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openapi): use snake_case when generating OpenAPI schema #702

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Jun 14, 2023

Description

Configure OpenAPI to output field names that match what's returned by the actual API.

Expected:

{
  "CrossChainTx": [
    {
      "creator": "zeta18pksjzclks34qkqyaahf2rakss80mnusju77cm",
      "index": "0x0e7627335d1ca4422b8171288741403792626448da268d6902e6dc3a921fbd79",
      "zeta_fees": "0",
      "relayed_message": "",
      "cctx_status": {
        "status": "OutboundMined",
        "status_message": "First half of EVM transfer Completed",
        "lastUpdate_timestamp": "1686603271"
      },
      "inbound_tx_params": {
        "sender": "0x6dA30bFA65E85a16b05bCE3846339ed2BC746316",
        "sender_chain_id": "5",
        "tx_origin": "0x6dA30bFA65E85a16b05bCE3846339ed2BC746316",
        "coin_type": "Gas",
        "asset": "",
        "amount": "100000000000000000",
        "inbound_tx_observed_hash": "0x71d493c395606050a75c79328a9a77c10bc92a7be144655c153fe7a7954b4e84",
        "inbound_tx_observed_external_height": "9168040",
        "inbound_tx_ballot_index": "0x0e7627335d1ca4422b8171288741403792626448da268d6902e6dc3a921fbd79",
        "inbound_tx_finalized_zeta_height": "0"
      },
      "outbound_tx_params": [
        {
          "receiver": "0x6dA30bFA65E85a16b05bCE3846339ed2BC746316",
          "receiver_chainId": "7001",
          "coin_type": "Gas",
          "amount": "0",
          "outbound_tx_tss_nonce": "0",
          "outbound_tx_gas_limit": "90000",
          "outbound_tx_gas_price": "",
          "outbound_tx_hash": "",
          "outbound_tx_ballot_index": "",
          "outbound_tx_observed_external_height": "0"
        }
      ]
    }
  ],
  "pagination": {
    "next_key": "MHgxOWY0NTVkYjNhNGU3MWQ0MWM5ZGFjNTgzYzY5Y2Q4MDU1NWUxZGM0OWI2NDZmOGMwZDVkMjA5NTcwM2Y3YWYw",
    "total": "0"
  }
}

Source: https://zetachain-testnet.nodejumper.io:1317/zeta-chain/crosschain/cctx?pagination.limit=1

Before the fix:

Screenshot 2023-06-14 at 09 35 41

After the fix:

Screenshot 2023-06-14 at 09 36 46

To check it out, run:

go run docs/main.go

Details:

https://grpc-ecosystem.github.io/grpc-gateway/docs/development/grpc-gateway_v2_migration_guide/#we-now-use-the-camelcase-json-names-by-default

Context:

https://zetachain.slack.com/archives/C0263N9EKL6/p1686676457123299

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation updat

@fadeev fadeev requested review from mgrabina and brewmaster012 June 14, 2023 05:38
@fadeev fadeev changed the title fix: json_names_for_fields=false in openapi fix(openapi): use snake_case when generating OpenAPI schema Jun 14, 2023
Copy link
Collaborator

@brewmaster012 brewmaster012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it!

@fadeev fadeev merged commit cf84fb0 into develop Jun 14, 2023
@brewmaster012 brewmaster012 deleted the fix/openapi branch June 14, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants