The Movie Database 支持

Have been debugging for 4h why Hasura wouldn't accept the TMDB spec, I took a very round about approach to solving my issue as I got an error of Invalid spec: right-hand side of 'in' should be an object, got undefined. In the end I decided to do some simple binary search with a json editor to find the offending path, in 20 minutes I found that the path movie/{movie_id}/changes has no defined response schema object. Leading to that weird error. Why is this? Is there a specific reason or just an oversight? @TravisBell

I got Hasura to parse the schema by removing the content field on the 200 response object in the offending path. Needless to say, I screamed so loudly and ear raped my roommate once I got it working. I've had this issue back in March 2023, but I just got round to taking a look at the project again. Sorry roommate.

6 回复(第 1 页,共 1 页)

Jump to last post

Btw, I used a custom script found in https://chat.openai.com/share/f0818c2d-ab1f-4ae1-b318-ae13306fb72e that removed the examples from all paths as it was causing some memory issues with the Hasura web portal.

const readline = require('readline');

// Function to remove example responses
function removeExampleResponses(oas) {
  if (!oas || typeof oas !== 'object') {
    throw new Error('Invalid input: OAS object is required');
  }

  // Iterate through paths
  for (const path in oas.paths) {
    const pathObject = oas.paths[path];

    // Iterate through HTTP methods (e.g., get, post, etc.)
    for (const method in pathObject) {
      const methodObject = pathObject[method];

      // Check if responses exist
      if (methodObject.responses && typeof methodObject.responses === 'object') {
        // Iterate through response codes
        for (const responseCode in methodObject.responses) {
          const response = methodObject.responses[responseCode];

          // Remove the example property from the response object
          if (response && response.content && response.content['application/json'] && response.content['application/json'].example) {
            delete response.content['application/json'].example;
          }
        }
      }
    }
  }

  return oas;
}

// Read input from stdin
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

let input = '';

rl.on('line', (line) => {
  input += line;
});

rl.on('close', () => {
  try {
    const oasInput = JSON.parse(input);
    const oasWithoutExamples = removeExampleResponses(oasInput);
    console.log(JSON.stringify(oasWithoutExamples, null, 2));
  } catch (error) {
    console.error('Error processing input:', error.message);
  }
});

Hi @robigan,

Are you using a current version of the OAS file that can be found here: https://developer.themoviedb.org/openapi ?

I ask because you mention a file from 2023. Since that time in 2023, we have migrated off the old API docs provider, so that file is completely different from what is currently generated.

Yup, using the latest copy of the oas file found there. By 2023 I mean it was the week just after you had posted the new migrations.

Ok, got it.

Well, ya, ReadMe is the one generating those files so there's not much I can do. It's up to them to generate a valid spec. man_shrugging_tone2

@travisbell said:

Ok, got it.

Well, ya, ReadMe is the one generating those files so there's not much I can do. It's up to them to generate a valid spec. man_shrugging_tone2

True, but the response body on the aforementioned route is empty. Even on the official tmdb api viewer. On your side does the response body to that route show up?

How's it look now?

There was an extra object ({}) defined at the beginning of the response that shouldn't have been there.

找不到电影或节目?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)上一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区