openapi: "3.0.0"
info:
  version: 2.0.1
  title: Autocompletion
  description: "Description de l'API du service d'autocompletion de l'IGN"
servers:
 - url: https://wxs.ign.fr/essentiels/geoportail/geocodage/rest/0.1/completion
paths:
  /getCapabilities:
    get:
      tags:
      - getCapabilities
      summary: Découvrir le service
      description: "Découvrir le service: les opérations possibles, les ressources disponibles et les options proposées."
      operationId: getCapabilities
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Getcapabilities"
        404:
          description: Not found

  /:
    get:
      summary: Retourne des suggestions de complétion du texte
      operationId: completion
      tags:
        - completion
      parameters:
        - name: text
          in: query
          description: Le texte devant être completé
          required: true
          schema:
            type: string
          example: "2, avenue pasteur saint m"
        - name: terr
          in: query
          description: Une limitation de la zone de recherche de localisants
          required: false
          schema:
            type: string
            enum: ['METROPOLE','DOMTOM','75','75013','93160,97,77300']
          example: "DOMTOM"
        - name: poiType
          in: query
          description: "Filtre sur le type de localisant pour le type POI.
          Les valeurs possibles sont listées dans le getCapabilities du service d'autocompletion."
          required: false
          schema:
            type: string
          example: "administratif"
        - name: lonlat
          in: query
          description: "coordonnées (longitude,latitude) d'un localisant pour favoriser les candidats les plus proches."
          schema:
            type: string
            pattern: '^\d+\.?\d*\,\d+\.?\d*$'
        - name: type
          in: query
          description: "Le type de localisants recherchés.
          Il est possible de spécifier plusieurs types séparés par une virgule."
          required: false
          schema:
            type: string
            enum: ['PositionOfInterest','StreetAddress','PositionOfInterest,StreetAddress']
            default: 'PositionOfInterest,StreetAddress'
          example: ""
        - name: maximumResponses
          in: query
          description: Le nombre maximum de réponses que l’on souhaite voir retournées (entre 1 et 15)
          required: false
          schema:
            type: integer
            default: 10
        - name: bbox
          in: query
          description: Filtre avec une bbox suivant l'ordre xmin,ymin,xmax,ymax
          required: false
          schema:
            type: string
            pattern: '^\d+\.?\d*\,\d+\.?\d*\,\d+\.?\d*\,\d+\.?\d*$'
      responses:
        '200':
          description: Une liste de suggestions de completions possibles
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Response"
              example:
                {
                  "status":"OK",
                  "results":[
                    {
                      "country":"StreetAddress",
                      "city":"Saint-Malo",
                      "x":-2.004141,
                      "y":48.655722,
                      "zipcode":"35400",
                      "street":"2 av pasteur",
                      "classification":7,
                      "kind":"",
                      "fulltext":"2 av pasteur,35400 Saint-Malo"

                    }
                  ]
                }
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                value: {
                  "status":"OK",
                  "results":[]
                }
components:
  schemas:
    Getcapabilities:
      type: "object"
      properties:
        info:
          type: "object"
          properties:
            name:
              type: "string"
            url:
              type: "string"
            description:
              type: "string"
        api:
          type: "object"
          properties:
            name:
              type: "string"
              example: "rest"
            version:
              type: "string"
              example: "0.0.0"
        operations:
          type: "array"
          items:
            type: "object"
            properties:
              id:
                type: "string"
              description:
                type: "string"
              url:
                type: "string"
              methods:
                type: "array"
                items:
                  type: "string"
                  enum: ["GET","POST","PUT","DELETE"]
              parameters:
                type: "array"
                items:
                  type: "object"
                  properties:
                    name:
                      type: "string"
                    in:
                      type: "string"
                    description:
                      type: "string"
                    required:
                      type: "boolean"
                    default:
                      description: "default value"
                    schema:
                      type: "object"
                      properties: 
                        type: 
                          type: "string"
                        example:
                          type: "string"
                    example:
                      type: "string"
        indexes:
          type: "array"
          items:
            type: "object"
            properties:
              id:
                type: "string"
              description:
                type: "string"
              fields:
                type: "array"
                items:
                  type: "object"
                  properties:
                    name:
                      type: "string"
                    description:
                      type: "string"
                    type:
                      type: "string"
                    queryable:
                      type: "boolean"
                    filter:
                      type: "boolean"
                    values:
                      type: "array"
                      items:
                        description: allowed value
    Response:
      type: object
      required:
        - status
        - results
      properties:
        status:
          type: string
        results:
          type: array
          items:
            $ref: "#/components/schemas/Address"
    Address:
      type: object
      required:
        - country
        - city
        - x
        - y
        - zipcode
        - street
        - classification
        - kind
        - fulltext
      properties:
        country:
          type: string
        city:
          type: string
        x:
          type: number
          format: float
        y:
          type: number
          format: float
        zipcode:
          type: string
          minLength: 5
          maxLength: 5
        street:
          type: string
        classification:
          type: integer
          format: int32
        kind:
          type: string
        fulltext:
          type: string
    Error:
      type: object
      required:
        - status
        - results
      properties:
        status:
          type: string
        results:
          type: array
          items:
            type: object
            maxItems: 0
