Forum Discussion

smatteoda's avatar
smatteoda
New Contributor
3 years ago

Using path parameters in domains

Hi, trying to use a path parameter in a Domain like:

States:
get:
tags:
- meta
summary: Get states by country
security:
- ApiKeyAuth: [ ]
operationId: getStatesByCountry
description: |
Get states by country
parameters:
- $ref: '#/components/parameters/IsoCodePathParam'


parameters:

IsoCodePathParam:
in: path
name: isoCode
required: true
description: Country ISO code
schema:
type: string
example: ES

 

Offers an error: Path parameter "isoCode" must have the corresponding {isoCode} segment in the "pathitems" path

 

Since in Domains, I can only have PathItems, like "States", and not paths.... how do I specify the segment?

  • smatteoda's avatar
    smatteoda
    New Contributor

    Well, it seems to work, despite of the UI complaining about it...

     

     

    • mhiggins's avatar
      mhiggins
      Staff

      as i am not replicate the problem, i will leave it up to you to decide if you want to open a Support Ticket.

       

  • Question 1: so is the API:

     

    paths:

      /some/new/path/{isoCode}

      $ref: '........#/components/pathitems/States'

     

    Question 2: is the parameter component defined as a domain reference or a local anchor ?

     

  • smatteoda's avatar
    smatteoda
    New Contributor

    Hi, 

    The parameter is defined in the domain as local anchor - $ref: '#/components/parameters/IsoCodePathParam' where States is defined.

    The API would later be 

    paths:

      /some/new/path/{isoCode}

      $ref: '........#/components/pathitems/States'

     

    But, I have not defined the API yet, just the domain... and it´s in the domain file I get the error.

    I´m attaching my file for reference...