googleapis / googleapis/google-api-nodejs-client
Incorrect typing in @googleapis/healthcare
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 12.3k
- Fork
- 2k
- Merge medio
- 1g 9h
- PR unite (30g)
- 24
Descrizione
Environment details
- OS: macOS Sonoma 14.4.1
- Node.js version: 20.5.1
- npm version: 9.8.0
@googleapis/healthcareversion: 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalle definizioni healthcare generate in src/apis/healthcare/v1.ts, in particolare dai tipi di request e response citati nel report, e confrontali con l’esempio FHIR collegato. Verifica i tipi corretti rispetto alla chiamata createFhirResource mostrata e ai dati restituiti; il lavoro è completato quando l’esempio viene compilato senza workarounds e corrisponde alla risposta dell’API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- nodejs, typescript
- Ambito
- api
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100