cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Define schemas for models in the API?

Highlighted
Conversationalist

Define schemas for models in the API?

Would it be possible to actually define the schema for the responses in the API?  I'm using a generator tool (janephp) to generate a library to work with the Meraki API and if the models are defined in the schema (vs using x-is-dynamic) really helps to get entity classes defined with various error checking defined in the API spec - property types, nullable or not etc.  As an example, here's a workup for the getNetworkDevices API call:

 

 

    get:
      tags:
      - Devices
      summary: List the devices in a network
      description: List the devices in a network
      operationId: getNetworkDevices
      parameters:
      - name: networkId
        in: path
        required: true
        schema:
          type: string
      responses:
        200:
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkDevices'

...

components:
  schemas:
    NetworkDevice:
      type: object
      properties:
        lat:
          type: float
          nullable: true
        lng:
          type: float
          nullable: true
        address:
          type: string
          nullable: true
        serial:
          type: string
        mac:
          type: string
        wan1Ip:
          type: string
        wan2Ip:
          type: string
          nullable: true
        lanIp:
          type: string
        url:
          type: string
        networkId:
          type: string
        model:
          type: string
        firmware:
          type: string
        floorPlanId:
          type: string
          nullable: true
    NetworkDevices:
      type: array
      items:
        $ref: '#/components/schemas/NetworkDevice'

 

 

With just having x-is-dynamic, I just get an object with a batch of public properties and my client itself has no knowledge of anything so I'd have to do a whole lot of checking if a property exists etc which makes for some ugly code.

 

Even the recent moves to finally stating the responses are application/json instead of text/plain has helped a lot.  It's really starting to get to where we can put together some nice automations to make managing our environment a lot easier.

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.