Ask a Question

OpenAPI: xml

chris01
New Contributor

OpenAPI: xml

Hello,

 

I would like to define for a put request a request body as described:

 

<startupConfig>
    <kroneMaterialNumbers>
        <KMAT number="204241000" nameProduktstrukturService="BX404-10">
            <WorkingSteps>
                <WorkingStep OrderNr="1">stepSetup</WorkingStep>
                <WorkingStep OrderNr="2">stepKSC</WorkingStep>
 
Because of Working Step is an array I can't find a solution to describe the attribute "OrderNr" in OpenAPI 3.0
 
I tried to use properties 
 
WorkingStep :
  type: array
  properties:
  1. properties:
  2.   number:
  3.     type: integer
  4.     xml:
  5.      attribute: true

  items:
   ...
 
but no attributes are display or generated.
 
Can anyone help?
2 REPLIES 2
chichepo
Contributor

@chris01 

I tried this definition:

 

components:
  schemas:
    KroneMaterialNumbers:
      type: object
      properties:
        kroneMaterialNumbers:
          $ref: '#/components/schemas/KMAT'
      xml:
        attribute: true
        name: kroneMaterialNumbers
    KMAT:
      type: object
      xml:
        name: KMAT
      properties:
        number:
          type: string
          example: 204241000
          xml:
            attribute: true
        nameProduktstrukturService:
          type: string
          example: BX404-10
          xml:
            attribute: true
        workingSteps:
          $ref: '#/components/schemas/WorkingSteps'
          
    WorkingSteps:
      type: array
      items:
        $ref: '#/components/schemas/WorkingStep'
      xml:
        wrapped : true
        name: WorkingSteps

    WorkingStep:
      type: object
      xml: 
        name: WorkingStep
      properties:
        OrderNr:
          type: string
          example: 1
          xml:
            attribute: true

 

 

I get this:

chichepo_0-1664462868006.png


By the way, you can check this page

Let me know

Hello Chichepo,

 

thanks for your answer. My problem is, by your solutions you get an array like this:

 

        <KMAT number="204241000" nameProduktstrukturService="BX404-10">
            <WorkingSteps>
                <WorkingStep OrderNr="1">stepSetup</WorkingStep>
            </WorkingSteps>
            <WorkingSteps>
                <WorkingStep OrderNr="2">stepSetup</WorkingStep>
            </WorkingSteps>
        </KMAT>

 

but what I'm looking for is to process this kind of input:

 

        <KMAT number="204241000" nameProduktstrukturService="BX404-10">
            <WorkingSteps>
                <WorkingStep OrderNr="1">stepSetup</WorkingStep>
                <WorkingStep OrderNr="2">stepKSC</WorkingStep>
                <WorkingStep OrderNr="3">stepCleanHubDrive</WorkingStep>
                <WorkingStep OrderNr="4">stepHeadersimulator</WorkingStep>
                <WorkingStep OrderNr="5">stepParkBrake</WorkingStep>
                <WorkingStep OrderNr="6">stepFieldSimulationHighPressureFor</WorkingStep>
                <WorkingStep OrderNr="7">stepFieldSimulationHighPressureBack</WorkingStep>
                <WorkingStep OrderNr="8">stepFieldSimulationIntake1</WorkingStep>
                <WorkingStep OrderNr="9">stepFieldSimulationIntake2</WorkingStep>
                <WorkingStep OrderNr="10">stepFieldSimulationHeader</WorkingStep>
                <WorkingStep OrderNr="12">stepSpeedForwardRoad</WorkingStep>
                <WorkingStep OrderNr="11">stepMRDT</WorkingStep>
            </WorkingSteps>
        </KMAT>

 

The function which I want to implement is to import a given set xmls and I can't change the format because of it is still be used.

 

Regards 

cancel
Showing results for 
Search instead for 
Did you mean: