Parse JSON/YAML file from C# Winform application

Viewed 27

I am having one yaml file with several endpoints. How to parse YAML/JSON file programmatically in C#, with corresponding Parameters, Body, Response etc.

example, If that file contains a post endpoint and Request body as shown below,

requestBody:
   content:
       application/json; charset=utf-8:
       schema:
            $ref: "#/components/schemas/CreateSample"
   
CreateSample:
      title: Sample
      description: The input data for the create sample.
      type: object
      properties:
        sampleValue:
          description: Test
          type: string
          maxLength: 80
        sampleId:
          description: Test ID.
          maxLength: 1000
          type: string

I have to get the body param in string as shown below.

{
  "sampleValue": "string",
  "sampleId": "string"
}
0 Answers
Related