Can you have a schema on a get function?


#1

I’m using a schema on a GET function when status is 200, to make sure that the returned values match those that are required.

  /newExample:
    get:
      description: |
        Gets a list of all of the Examples 
      responses:
        200:
          body:
            application/json:
              example: !include resources/json/new-example.json
              schema: !include resources/json/new-example-schema.json
        404:
          body:
            application/json:
              example: !include resources/json/example/error/error-example.json

and when i use this code i get a warning saying that the schema was not recognised, am i using the correct code?


#2

Are you sure your schema is valid? It usually happens when it isn’t.


#3

Hi,

my schema looks a bit like this (there’s a fair few more fields but they’re all set u the same):

{
  "$schema": "http://json-schema.org/example/schema",
    "title": "example",
    "type": "object",
    "required": [ "example1"], 
    "properties":    
    { 
      "example1"
      {
        "type":"integer"
      }
      "example2"
      {
        "type":"string"
        "format":"string"
      }
}

#4

There is a comma missing between your two property declarations :slight_smile: Can you try this validator, please? Just copy and paste your schema into the left text box.


#5

Thank you Christian, this solved my issues. I was missing a bit of syntax.


#6

The warnings will come for any syntax error like missing any commas or quotation etc. please check carefully once