1

I have some shocking response JSON to work with from an internal client. They can't change it on the fly unfortunately as multiple teams are sending them requests and already dealing with this horrendous response.

My question is, is there any way to use OpenAPI to build an object structure which will map the incoming JSON below, with the, frankly, moronic name/value setup as you can see:

{
    "data": [{
            "name": "something",
            "value": "123"
        },
        {
            "name": "something2",
            "value": "str"
        },
        {
            "name": "something3",
            "value": "str123"
        },
        {
            "name": "something4",
            "value": "str456"
        },
        {
            "name": "something5",
            "value": "str333"
        },
        {
            "name": "something6",
            "value": "str333rr"
        },
        {
            "name": "something7",
            "value": "str333rr322"
        },
        {
            "name": "something8",
            "value": "str333rr354"
        },
        {
            "name": "something9:",
            "value": "str333rr354543"
        }
    ]
}

1 Answer 1

3

I don't really see the complexity of this JSON, I've quickly done something in the swagger editor to match the structure:

  NameValue:
    type: object
    properties:
      name:
        type: string
      value:
        type: string

  ResultSet:
    type: object
    properties:
      data:
        type: array
        items:
          $ref: '#/definitions/NameValue'

Am I missing something ?

Sign up to request clarification or add additional context in comments.

1 Comment

I literally just discovered array type in openapi, I'm just starting off with it, and an idiot. Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.