Score:1

Can we export json schemas for type script usage?

fr flag

We have a Drupal installation that acts as a backend and a front end that uses the HttpClientModule from Angular to query this data.

Thanks to the typescript base, we can provide the functions of this service with the expected return type like this.httpClient.get<ExpectedTypeInterface>(urlToJsonResource). The important question is: Where does the implementation of the ExpectedTypeInterface come from?

Wehn I inspect our API via OpenAPI/Swagger UI, I see that there is schema information available. Is there a standard way of exporting this information into typescript interfaces?

Creating them by hand would be a bad choice, because than the front end might get outdated type definitions.

Score:-2
fr flag

OpenAPI offers an endpoint under /openapi/rest?_format=json that delivers the complete json schema. For the transformation, we need the node package json-schema-to-typescript. This package offers a cli that lets us transform the json schema into a typescript file.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.