Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Incorrect typing in @googleapis/healthcare

未关闭
#3,490 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
nodejs, typescript
领域
api

调研方向

从 src/apis/healthcare/v1.ts 中生成的 healthcare 定义开始,尤其是报告中引用的 request 和 response 类型,并将它们与链接的 FHIR 示例进行比较。根据所示的 createFhirResource 调用及其返回的数据验证修正后的类型;当示例无需 workarounds 即可编译并与 API 响应匹配时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

priority: p2 type: bug
Environment details
  • OS: macOS Sonoma 14.4.1
  • Node.js version: 20.5.1
  • npm version: 9.8.0
  • @googleapis/healthcare version: 16.0.0

Hi there- following the example code for creating FHIR resources, it seems the generated types do not match what the api expects.

Running the example code indicates the requestBody is mistyped and should be of type Scehma$HttpBody.

The response is also mistyped as it seems to return a BLOB. Below is the example code with comments added. This was tested using valid config variables.

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
	version: 'v1',
	auth: new google.auth.GoogleAuth({
		scopes: ['https://www.googleapis.com/auth/cloud-platform'],
	}),
	headers: { 'Content-Type': 'application/fhir+json' },
});

async function createFhirResource() {
	// Replace the following body with the data for the resource you want to
	// create.
	const body = {
		name: [{ use: 'official', family: 'Smith', given: ['Darcy'] }],
		gender: 'female',
		birthDate: '1970-01-01',
		resourceType: 'Patient',
	};

	// TODO(developer): uncomment these lines before running the sample
	// const cloudRegion = 'us-central1';
	// const projectId = 'adjective-noun-123';
	// const datasetId = 'my-dataset';
	// const fhirStoreId = 'my-fhir-store';
	// const resourceType = 'Patient';

	// Example code request - type errors for `requestBody`, returns 200
	const request = { parent, type: resourceType, requestBody: body };
	const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.create(request);

	// Modified to satisfy type errors, throws 400
	// const request = { parent, type: resourceType, requestBody: { data: JSON.stringify(body) } };
	// const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.create(request);

	// Example code response - `id` is undefined, `resource.data` is a BLOB.  Type error: Property 'id' does not exist on type 'Schema$HttpBody'.
	// console.log(`Created FHIR resource with ID ${resource.data.id}`);
	// console.log(resource.data);

	// Modified to parse response correctly, throws type errors
	const textData = await resource.data.text();
	const parsedData = JSON.parse(textData);
	console.log(`Created FHIR resource with ID ${parsedData.id}`);
	console.log(parsedData);
}

createFhirResource();

It seems there have been a couple other similar issues in the other api libraries.
See: #1944 and #1168

主要语言
TypeScript
星标
12.3k
派生
2k
平均合并
2 天 19 小时
30 天内合并 PR
23

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleapis/google-api-nodejs-client 的其他 Issue

查看 googleapis/google-api-nodejs-client 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。