Skip to content

Commit 1354d3c

Browse files
committed
Add npx get dtos post
1 parent 0ad2df0 commit 1354d3c

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: DTOs in all languages downloadable without .NET
3+
summary: ServiceStack Typed DTOs for all languages can now be downloaded and uploaded without .NET installed
4+
tags: [api,service-reference,js]
5+
author: Demis Bellot
6+
image: https://images.unsplash.com/photo-1639262498805-17c7dc422d37?crop=entropy&fit=crop&h=1000&w=2000
7+
draft: true
8+
---
9+
10+
To make it easier to consume ServiceStack APIs in any language, we've added the ability to download and upload Typed DTOs
11+
in all languages without needing .NET installed with the new `npx get-dtos` npm script.
12+
13+
It has the same syntax and functionality as the `x` dotnet tool for adding and updating ServiceStack References where
14+
in most cases you can replace `x <lang>` with `npx get-dtos <lang>` to achieve the same result.
15+
16+
Running `npx get-dtos` without any arguments will display the available options:
17+
18+
get-dtos <lang> Update all ServiceStack References in directory (recursive)
19+
get-dtos <file> Update existing ServiceStack Reference (e.g. dtos.cs)
20+
get-dtos <lang> <url> <file> Add ServiceStack Reference and save to file name
21+
get-dtos csharp <url> Add C# ServiceStack Reference (Alias 'cs')
22+
get-dtos typescript <url> Add TypeScript ServiceStack Reference (Alias 'ts')
23+
get-dtos javascript <url> Add JavaScript ServiceStack Reference (Alias 'js')
24+
get-dtos python <url> Add Python ServiceStack Reference (Alias 'py')
25+
get-dtos dart <url> Add Dart ServiceStack Reference (Alias 'da')
26+
get-dtos php <url> Add PHP ServiceStack Reference (Alias 'ph')
27+
get-dtos java <url> Add Java ServiceStack Reference (Alias 'ja')
28+
get-dtos kotlin <url> Add Kotlin ServiceStack Reference (Alias 'kt')
29+
get-dtos swift <url> Add Swift ServiceStack Reference (Alias 'sw')
30+
get-dtos fsharp <url> Add F# ServiceStack Reference (Alias 'fs')
31+
get-dtos vbnet <url> Add VB.NET ServiceStack Reference (Alias 'vb')
32+
get-dtos tsd <url> Add TypeScript Definition ServiceStack Reference
33+
34+
Options:
35+
-h, --help, ? Print this message
36+
-v, --version Print tool version version
37+
--include <tag> Include all APIs in specified tag group
38+
--qs <key=value> Add query string to Add ServiceStack Reference URL
39+
--verbose Display verbose logging
40+
--ignore-ssl-errors Ignore SSL Errors
41+
42+
### Reusable DTOs and Reusable Clients in any language
43+
44+
A benefit of [Add ServiceStack Reference](https://docs.servicestack.net/add-servicestack-reference) is that only an
45+
API DTOs need to be generated which can then be used to call any remote instance running that API. E.g. DTOs generated
46+
for our deployed AI Server instance at [openai.servicestack.net](https://openai.servicestack.net) can be used to call
47+
any self-hosted AI Server instance, likewise the same generic client can also be used to call any other ServiceStack API.
48+
49+
### TypeScript Example
50+
51+
For example you can get the TypeScript DTOs for the just released [AI Server](/posts/ai-server) with:
52+
53+
:::sh
54+
`npx get-dtos typescript https://openai.servicestack.net`
55+
:::
56+
57+
Which just like the `x` tool will add the TypeScript DTOs to the `dtos.ts` file
58+
59+
And later update all TypeScript ServiceStack References in the current directory with:
60+
61+
:::sh
62+
`npx get-dtos typescript`
63+
:::
64+
65+
### Install and Run in a single command
66+
67+
This can be used as a more flexible alternative to the `x` tool where it's often easier to install node in CI environments
68+
than a full .NET SDK and easier to use npx scripts than global dotnet tools. For example you can use the `--yes` flag
69+
to implicitly install (if needed) and run the `get-dtos` script in a single command, e.g:
70+
71+
:::sh
72+
`npx --yes get-dtos typescript`
73+
:::
74+
75+
### C# Example
76+
77+
As such you may want want to replace the `x` dotnet tool with `npx get-dtos` in your C#/.NET projects as well which
78+
can either use the language name or its more wrist-friendly shorter alias, e.g:
79+
80+
:::sh
81+
`npx get-dtos cs https://openai.servicestack.net`
82+
:::
83+
84+
Then later update all C# DTOs in the current directory (including sub directories) with:
85+
86+
:::sh
87+
`npx get-dtos cs`
88+
:::

0 commit comments

Comments
 (0)