How to GET file contents in the response model

Created on 4 October 2024, about 2 months ago

Problem/Motivation

I'm trying to get this response with this module.

My my_custom_module.http_services_api.yml:

monkey:
  title: MonKey
  api_path: /api/monkey.yml
  config:
    base_uri: https://monkey.banano.cc
    stream: true

(I've tried both with or without stream:true).

My my_custom_module/api/monkey.yml:

name: MonKey
apiVersion: v1
description: Returns a MonKey SVG for each banano address
imports:
  - resources/banano/monkey.yml

My my_custom_module/api/resources/banano/monkey.xml:

operations:
  GetSVG:
    httpMethod: GET
    uri: "/api/v1/monkey/{address}"
    summary: "SVG by Banano address"
    responseModel: SVG
    parameters:
      address:
        location: uri
        description: "Banano address"
        type: string
        required: true
      format:
        location: query
        description: Format (svg/png/webp)
        type: string
      size:
        location: query
        description: Pixel size (100<=128<=1000)
        type: integer
      background:
        location: query
        description: Colored background (false)
        type: boolean

models:
  SVG:
    type: object
    location: json

The operations should be OK, and problem is probably in the SVG model. I've tried with:

  1. type: object
    location: xml
  2. type: object
    location: json

but the response is always empty, with no errors logged:

The simple API, as you can see at https://monkey.banano.cc/documentation, can return either SVG, PNG or Webp files, and I plan to save either of them (preferably svg) as Drupal-managed files, to be referenced by a content entity.

💬 Support request
Status

Active

Version

10.0

Component

Documentation

Created by

🇮🇹Italy kopeboy Milan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024