Schema error should NOT have additional properties additionalProperty: @odata.context, @odata.etag

206 views
Skip to first unread message

Vinay Banakar

unread,
Oct 30, 2017, 4:28:44 AM10/30/17
to Swagger

Hello,

I am using http://editor.swagger.io, wheere I have a validated JSON file I am trying to create a pojo of it. But when I copy the json to the editor it prompts me to convert it to YAML, once that's done the editor throws the bellow error.

Schema error 

should NOT have additional properties additionalProperty: @odata.context, @odata.etag, @odata.id, @odata.type

But it  is a valid JSON data, can someone help me figure out why I am encountering this error to beign with?

Thank you

Ron Ratovsky

unread,
Oct 30, 2017, 3:24:51 PM10/30/17
to swagger-sw...@googlegroups.com

Valid JSON doesn’t mean it’s a valid OpenAPI document.

In order to point you to the issue, we need to see the full definition.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Darshan A.N.

unread,
Mar 6, 2018, 5:10:22 AM3/6/18
to Swagger
Hi Ron,
I m also facing the same issue. I have pasted my yaml code. Please look into it.

swagger: "2.0"
info:
  version: "0.0.1"
  title: User Operations
# during dev, should point to your local machine
host: localhost:10010
# basePath prefixes all resource paths 
basePath: /
schemes:
  # tip: remove http to make production-grade
  - http
  - https
# format of bodies a client can send (Content-Type)
consumes:
  - application/json
# format of the responses to the client (Accepts)
produces:
  - application/json
paths:
  /user/source:
    # binds a127 app logic to a route
    x-swagger-router-controller: source
    get:
      description: Returns list of Users
      # used as the method name of the controller
      operationId: getAll
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/User"
        # responses may fall through to errors
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
    put:
      summary: to edit Users details 
      description: edit all the users to database
      operationId: save
      parameters:
        - name: edit user details
          in: body
          required: true
          schema:
            $ref: "#/definitions/User"
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GeneralResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
  /user/source/{sourceId}:
    x-swagger-router-controller: userlist
    get:
      operationId: getOne
      description: get a movie
      # define the type of response for Success "200" and Error
      parameters:
        - name: sourceId
          type: string
          in: path
          required: true
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GenearalResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
    put:
      operationId: update
      description: update a user
      # define the parameters
      parameters:
        - name: sourceName
          description: User Properties
          in: body
          required: true
          schema:
            $ref: "#/definitions/User"
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GeneralResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
    delete:
      operationId: delUser
      description: remove a user from database
      parameters: 
        - name: sourceId
          description: enter Unique sourceId
          type: string
          in: path
          required: true
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GeneralResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
  /user/source/{sourceId}/schema:
    put:
      summary: A brief summary of the operation.
      description: A brief summary of the operation.
      operationId: saveKeyValue
      parameters:
        - name: sourceId
          description: enter Unique sourceId
          in: path
          required: true
          schema:
            $ref: "#/definitions/User"
      responses:
        "200":
          description: success
          schema:
            $ref: "#/definitions/GeneralResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
    get:
      description: get the particular user information
      operationId: getSchema
      parameters: 
        - name: sourceId
          description: enter Unique sourceId
          type: string
          in: path
          required: true
          schema:
            $ref: "#/definitions/User"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/GeneralResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
  /swagger:
    x-swagger-pipe: swagger_raw
# complex objects have schema definitions
definitions:
  Schema:
    properties:
      key:
        type: string
      value:
        type: string
  User:
    required:
      - sourcename
      - sourceId
      - sourceType
    properties: 
      sourcename:
        type: string
      sourceId:
        type: string
      sourceDescription:
        type: string
      sourceType:
        type: string
      sourceSchema:
        type: object
        additionalProperties:
          type: string
  GeneralResponse:
    type: object
    properties:
      success:
        type: number
        description: returns 1 if successful
      description:
        type: string
        description: a short comment 
    required:
      - success
      - description
  ErrorResponse:
    required:
      - message
    properties:
      message:
        type: string

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages