Skip to content

Commit e58cc4a

Browse files
committed
Incorporate npx get-dtos to docs
1 parent 92a1d09 commit e58cc4a

10 files changed

+141
-26
lines changed

MyApp/_includes/npx-get-dtos.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Alternative (without .NET): npx get-dtos
2+
3+
Alternatively API consumers can use [npx get-dtos](/npx-get-dtos) to Add/Update ServiceStack References without needing .NET installed, where any command starting with:
4+
5+
```txt
6+
x <lang>
7+
```
8+
9+
Can be replaced with:
10+
11+
```txt
12+
npx get-dtos <lang>
13+
```
14+
15+
To instead Add / Update ServiceStack references using the npm get-dtos package.

MyApp/_pages/dart-add-servicestack-reference.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ Dart ServiceStack Reference supports **all Dart 2.0 platforms**, including Flutt
1919
Due to the lack of reflection and Mirror support, consuming JSON APIs can be quite [cumbersome in Flutter](https://flutter.io/cookbook/networking/fetch-data/). But we've been able to achieve the same productive development experience available in [all supported languages](/add-servicestack-reference) where you can use the generated Dart DTOs from any remote v5.1+ ServiceStack endpoint with ServiceStack's Smart generic
2020
[JsonServiceClient](https://pub.dartlang.org/documentation/servicestack/0.0.7/client/JsonServiceClient-class.html) available in the [servicestack Dart package](https://pub.dartlang.org/packages/servicestack#-installing-tab-), to enable an end-to-end Typed API for calling Services by [sending and receiving native DTOs](/architecture-overview#client-architecture).
2121

22-
### Example Usage
22+
### Install
2323

2424
You can use the same [x dotnet tool](/dotnet-tool) simple command-line utility to easily Add and Update ServiceStack References for all supported languages:
2525

26-
Install [.NET Core](https://dotnet.microsoft.com/download) then install the `x` dotnet tool:
26+
Install [.NET SDK](https://dotnet.microsoft.com/download) then install the `x` dotnet tool:
2727

2828
:::sh
2929
dotnet tool install --global x
3030
:::
3131

32+
::include npx-get-dtos.md::
33+
34+
### Example Usage
35+
3236
You can then execute `x dart` with the URL of the remote ServiceStack Instance you want to generated DTOs for, e.g:
3337

3438
:::sh

MyApp/_pages/dotnet-tool.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ title: ServiceStack's .NET Core Utility Belt
55

66
Our `x` and `app` dotnet tools are a versatile invaluable companion for all ServiceStack developers where it's
77
jam packed with functionality to power a number of exciting scenarios where it serves as a [Sharp App](https://sharpscript.net/docs/sharp-apps)
8-
delivery platform where they can be run as a .NET Core Windows Desktop App with `app` or as a cross-platform Web App launcher
9-
using `web` and we've already how it's now a [`#Script` runner](https://sharpscript.net/docs/sharp-scripts) with `x run` and into a
8+
delivery platform where they can be run as a .NET Core Windows Desktop App with `app` or as a cross-platform Web App launcher using `web` and we've already how it's now a [`#Script` runner](https://sharpscript.net/docs/sharp-scripts) with `x run` and into a
109
[Live `#Script` playground](https://sharpscript.net/docs/sharp-scripts#live-script-with-web-watch) with `x watch`.
1110

1211
These tools contains all the functionality ServiceStack Developers or API consumers need that can be used
@@ -31,7 +30,11 @@ dotnet tool update -g x
3130
:::
3231

3332
::: info
34-
Both `x` and `app` have equivalent base functionality, whilst `app` has superset features for richer [Windows-only integration](/netcore-windows-desktop)
33+
Both `x` and `app` have equivalent base functionality, whilst `app` has superset [Windows-only Desktop features](/netcore-windows-desktop)
34+
:::
35+
36+
::: info
37+
To update and download Add ServiceStack Reference dtos without .NET see [npx get-dtos](/npx-get-dtos)
3538
:::
3639

3740
## Usage

MyApp/_pages/javascript-add-servicestack-reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ npm install -D @servicestack/client
108108

109109
Where only its TypeScript definitions are used by the IDE during development to enable its type-checking and intelli-sense.
110110

111+
::include npx-get-dtos.md::
112+
111113
### Rich intelli-sense support
112114

113115
Where you'll be able to benefit from rich intelli-sense support in smart IDEs like [Rider](https://www.jetbrains.com/rider/) for

MyApp/_pages/npx-get-dtos.md

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

MyApp/_pages/php-add-servicestack-reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ To install first install the [latest .NET SDK](https://dotnet.microsoft.com/down
228228
$ dotnet tool install --global x
229229
```
230230

231+
::include npx-get-dtos.md::
232+
231233
### Adding a ServiceStack Reference
232234

233235
To Add a PHP ServiceStack Reference just call `x php` with the URL of a remote ServiceStack instance:

MyApp/_pages/python-add-servicestack-reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ To install first install the [latest .NET SDK](https://dotnet.microsoft.com/down
155155
dotnet tool install --global x
156156
:::
157157

158+
::include npx-get-dtos.md::
159+
158160
### Adding a ServiceStack Reference
159161

160162
To Add a Python ServiceStack Reference just call `x python` with the URL of a remote ServiceStack instance:

MyApp/_pages/sidebar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
"text": "dotnet tool - Win/Mac/Linux Utils",
7373
"link": "/dotnet-tool"
7474
},
75+
{
76+
"text": "npx get-dtos",
77+
"link": "/npx-get-dtos"
78+
},
7579
{
7680
"text": "x new - Project Template",
7781
"link": "/dotnet-new"

MyApp/_pages/swift-add-servicestack-reference.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ $ dotnet tool install --global x
2121

2222
This will make the `x` dotnet tool available in your `$PATH` which can now be used from within a **Terminal window** at your Xcode project folder.
2323

24+
::include npx-get-dtos.md::
25+
26+
### Reference ServiceStack.Swift
27+
2428
To use the latest `JsonServiceClient` you'll need to add a reference to ServiceStack Swift library using your preferred package manager:
2529

2630
### Xcode
@@ -37,8 +41,7 @@ https://github.com/ServiceStack/ServiceStack.Swift
3741

3842
![](/img/pages/dev/xcode-add-servicestack-swift.png)
3943

40-
After adding the dependency both [ServiceStack.Swift](https://github.com/ServiceStack/ServiceStack.Swift) and its
41-
[PromiseKit](https://github.com/mxcl/PromiseKit) dependency will be added to your project:
44+
After adding the dependency [ServiceStack.Swift](https://github.com/ServiceStack/ServiceStack.Swift) will be added to your project:
4245

4346
![](/img/pages/dev/xcode-servicestack-swift-added.png)
4447

@@ -50,20 +53,15 @@ In your [Podfile](https://guides.cocoapods.org/syntax/podfile.html):
5053
use_frameworks!
5154

5255
# Pods for Project
53-
pod "ServiceStack", '~> 1.1'
54-
```
55-
56-
#### Carthage
57-
58-
```ruby
59-
github "ServiceStack/ServiceStack.Swift" ~> 1.1
56+
pod "ServiceStack", '~> 6.0.5'
6057
```
6158

6259
#### SwiftPM
6360

6461
```swift
6562
dependencies: [
66-
.package(url: "https://github.com/ServiceStack/ServiceStack.Swift", from: "1.0.0"),
63+
.package(url: "https://github.com/ServiceStack/ServiceStack.Swift.git",
64+
Version(6,0,0)..<Version(7,0,0)),
6765
],
6866
```
6967

@@ -74,11 +72,8 @@ Async usage example:
7472
```swift
7573
import ServiceStack
7674

77-
client.getAsync(AppOverview())
78-
.done { r in
79-
r.topTechnologies.count //= 100
80-
//...
81-
}
75+
let response = try await client.getAsync(AppOverview())
76+
print(response.topTechnologies.count) //= 100
8277
```
8378

8479
Sync usage example:
@@ -167,22 +162,25 @@ The header comments in the generated DTO's allows for further customization of h
167162

168163
```swift
169164
/* Options:
170-
Date: 2017-02-02 02:41:09
171-
SwiftVersion: 3.0
172-
Version: 4.55
165+
Date: 2024-11-28 10:23:42
166+
SwiftVersion: 6.0
167+
Version: 8.51
173168
Tip: To override a DTO option, remove "//" prefix before updating
174169
BaseUrl: https://techstacks.io
175170
176171
//BaseClass:
177172
//AddModelExtensions: True
178173
//AddServiceStackTypes: True
174+
//MakePropertiesOptional: True
179175
//IncludeTypes:
180176
//ExcludeTypes:
181-
//ExcludeGenericBaseTypes: True
177+
//ExcludeGenericBaseTypes: False
182178
//AddResponseStatus: False
183179
//AddImplicitVersion:
184-
//InitializeCollections: True
185-
//DefaultImports: Foundation
180+
//AddDescriptionAsComments: True
181+
//InitializeCollections: False
182+
//TreatTypesAsStrings:
183+
//DefaultImports: Foundation,ServiceStack
186184
*/
187185
```
188186

MyApp/_pages/typescript-add-servicestack-reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ The [dotnet tools](/dotnet-tool) include built in support for generating TypeScr
9696
dotnet tool install --global x
9797
:::
9898

99+
::include npx-get-dtos.md::
100+
99101
### Adding a ServiceStack Reference
100102

101103
To Add a TypeScript ServiceStack Reference just call `x typescript` with the URL of a remote ServiceStack instance:

0 commit comments

Comments
 (0)