How to write correct syntax of model json swagger in swagger editor (response from google geometry
Dear everybody,
I am newbie of swagger module, currently I would like to write the json swagger format to export existing file for use other application. My api service using is google geometry get lat, lng from locationname
Here is my url -> https://maps.googleapis.com/maps/api/geocode/
use 2 parameter are 1. apikey -> key : 'your apikey from google'
2. address -> address : 'Newyork, USA'
----------------------------------------------------------------------------------------
so My currently result from api is here
----------------------------------------------------------------------------------------
{
"results": [
{
"address_components": [
{
"long_name": "New York",
"short_name": "New York",
"types": [
"locality",
"political"
]
},
{
"long_name": "New York",
"short_name": "NY",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United States",
"short_name": "US",
"types": [
"country",
"political"
]
}
],
"formatted_address": "New York, NY, USA",
"geometry": {
"bounds": {
"northeast": {
"lat": 40.9175771,
"lng": -73.70027209999999
},
"southwest": {
"lat": 40.4773991,
"lng": -74.25908989999999
}
},
"location": {
"lat": 40.7127753,
"lng": -74.0059728
},
"location_type": "APPROXIMATE",
"viewport": {
"northeast": {
"lat": 40.9175771,
"lng": -73.70027209999999
},
"southwest": {
"lat": 40.4773991,
"lng": -74.25908989999999
}
}
},
"place_id": "ChIJOwg_06VPwokRYv534QaPC8g",
"types": [
"locality",
"political"
]
}
],
"status": "OK"
}
------------------------------------------------------------------------------------------
And currently my swagger editor (on process)
------------------------------------------------------------------------------------------
swagger: '2.0'
info:
description: 'API for https://maps.googleapis.com'
version: 1.0.0
title: Swagger geometry from location
host: maps.googleapis.com
schemes:
- http
paths: /maps/api/geocode:
$ref: '#/definitions/results'
'/maps/api/geocode/{key}':
get:
summary: Get lat, lng from location
description: return nearby lat lng from location
operationId: Getlatlng
produces:
- application/json
parameters:
- name: address
in: path
description: address detail
required: true
type: string
- name: key
in: query
description: Service's API Key
required: true
type: string
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/results'
definitions:
address component:
type: object
properties:
EnglishName:
type: string
ID:
type: string
LocalizedName:
type: string
address_component:
type: object
properties:
Country:
$ref: '#/definitions/address_component'
long_name: string
short_name: string
$type : '#/definitions/address_component'
type:
type: object
type: object
---------------------------------------------------------------------------------------------------------------
I am very confuse about how to call definition link with string and array.
please experience develop help me to find correct swagger format.
Thanks for advance.
pjp
correct format
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.