0

I have written a POST method for the input of 2 integers lon and lat. How can I calculate the sum of lon and lat and return it?

openapi: 3.0.0
info:
  version: '1.0.0'
  title: ''
  description: ''
paths:
  /coordinates:
    post:
      responses:
        '201':
          description: Created 
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                lon:          
                  type: number
                  format: double
                lat:    
                  type: number
                  format: double
AlexM88
  • 1
  • 2
  • To implement business logic you need a backend server. Is your question "how to *implement a server* that accepts 2 numbers via HTTP POST and returns their sum" OR "how to *write an OpenAPI definition* for a response that contains a number"? – Helen Sep 09 '19 at 10:58
  • I think my question is "how to write an OpenAPI definition for a response that contains a number" – AlexM88 Sep 09 '19 at 11:19
  • How does the response look like? It is just the number as plain text (i.e. `Content-Type: text/plain` and the response body is the text `12.3456`) or is it a JSON object (i.e. `{"sum": 12.3456}`) or something else? – Helen Sep 09 '19 at 12:24
  • The respone should be a JSON Object. – AlexM88 Sep 10 '19 at 07:37
  • Check out [Describing Responses - Response Body](https://swagger.io/docs/specification/describing-responses/#body). Response schemas are defined similar to request body schemas. – Helen Sep 10 '19 at 09:31

0 Answers0