API Connect

 View Only
  • 1.  Server variables

    Posted Fri March 10, 2023 04:58 AM

    Hi everyone,

    When defining an API we have a place to define server definitions.

    One of the options are the server variables. Can someone explain me the benefits of using it and how to do it?

    Regards.



    ------------------------------
    Filipe Ventura
    ------------------------------


  • 2.  RE: Server variables

    Posted Fri March 10, 2023 09:44 AM

    Hi Filipe,
    Definitions are used primarily for the validate and map policies.   They define the schema of some message body.   If you're importing a wsdl for a web service, these definitions are created automatically for you, but otherwise, you'll need to create them yourself.  There is a helper tool where you can provide a sample JSON or XML document and the schema will be created for you.  One caveat if you do have XML definitions is that the generation tool is not data type aware.  For example, 

    <element>true</element>

    is that value true a string "true" or a boolean true?   The same would be for numeric values, so some modification on your part of the generated schema may be required.   Finally if your XML has repeating elements allowed, you must specify repeating elements in your sample or the schema would specify it as a non-array.  If repeating elements are encountered at the same XML hierarchy, the element is known to be an array.

    From my experience, the map policy is more widely used than the validate policy.  The definition can be referenced by the input and output sides of the mapping, which would then allow you to map an input property to an output property in the APIM UI.

    As for "server variable", please explain where you're seeing that option.  Perhaps my commentary above on "definitions" is not what you are talking about with "server definitions"?

    Best Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: Server variables

    Posted Fri March 10, 2023 09:57 AM

    Hi Steve,

    Thanks helping me.

    I'm talking about this tab:

    Regards


    ------------------------------
    Filipe Ventura
    ------------------------------



  • 4.  RE: Server variables

    Posted Fri March 10, 2023 12:02 PM

    Thanks Filipe,
    Well my ignorance on this topic is showing that I have minimal experience with OAI3 APIs as this doesn't exist for OAI2 APIs :-)   This will be some new learning for me as well.  I'll post back if I learn something new.  Hopefully, someone else following this forum has some experience with OAI3 APIs and can help with your question.

    Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 5.  RE: Server variables

    Posted Fri March 10, 2023 01:38 PM
    Edited by Steve Linn Fri March 10, 2023 01:39 PM

    Hi Filipe,
    See the API Connect restrictions for Open API 3 at https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=definition-openapi-30-support-in-api-connect.  Although the UI was built to allow you to specify multiple servers and server variables, they are not supported in the gateway per the above link.  Only one server is allowed and variable substitution is not supported.  The OAI3 Server url in analogous to the OAI2 host, basepath, and schemes keywords.

    Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------