Informix

 View Only
Expand all | Collapse all

Informix SQL types to OpenAPI data types

  • 1.  Informix SQL types to OpenAPI data types

    Posted Tue May 11, 2021 03:51 AM
    Edited by System Fri January 20, 2023 04:21 PM

    Hello!

    I want to learn best practices about SQL data type to Swagger/OpenAPI data type mapping.

    I am looking for a REST API solution to access Informix SQL databases/tables (no JSON/MongoDB).
    Is there an equivalent of https://postgrest.org (PostgREST) tool with Informix IDS 14 ?

    OpenAPI spec (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#format, https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#schemaObject) defines the type/format attributes to describe a data type, but seems there is no clear solution for now to specify types such as DECIMAL(10,2) (with exact precision and scale)

    I found some discussions about having precision/scale attributes... but nothing about that in the spec.

    So far my understanding is that one can use the OpenAPI data type "format" attribute, to give details about the type, and if the REST service consumer is not able to understand that, it should behave as if "format" was not specified.

    For example, a DECIMAL(6,2) could be defined with:

    - type = "number"
    - format = "decimal(6,2)"
    - minimum = -9999.99
    - maximum = 9999.99
    - pattern = "reg-exp-for-such-numbers-covering-all-possibilities-including-exponent-notation"

    I understand that OpenAPI is to exchange data between heterogeneous software components and an abstract type definition makes it more flexible. But when you have a REST client and server that manipulate SQL-based types, you don't want to lose type information because the communication protocol only defines a subset of the SQL types. For ex, if the REST server-side stores numeric values in a DECIMAL(5,2) columns, the REST client must know that it can't provide values like 99999999.9999 ...

    Thanks for reading.
    Seb



    ------------------------------
    Sebastien FLAESCH
    ------------------------------
    #Informix


  • 2.  RE: Informix SQL types to OpenAPI data types

    Posted Fri May 14, 2021 09:50 AM
    The only tool I know for an Informix REST API is the one provided by the wire listener that comes bundled with the server install ( REST API ). The documentation does not mention OpenAPI anywhere, so it probably is not compliant with the standard.




    ------------------------------
    Luis Marques
    ------------------------------