@typespec/http-server-csharp 0.58.0-alpha.9-dev.0 → 0.58.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -6
- package/dist/src/cli/cli.js +92 -43
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/lib/attributes.d.ts.map +1 -1
- package/dist/src/lib/attributes.js +65 -31
- package/dist/src/lib/attributes.js.map +1 -1
- package/dist/src/lib/boilerplate.d.ts +1 -1
- package/dist/src/lib/boilerplate.d.ts.map +1 -1
- package/dist/src/lib/boilerplate.js +153 -31
- package/dist/src/lib/boilerplate.js.map +1 -1
- package/dist/src/lib/doc.d.ts +5 -0
- package/dist/src/lib/doc.d.ts.map +1 -0
- package/dist/src/lib/doc.js +237 -0
- package/dist/src/lib/doc.js.map +1 -0
- package/dist/src/lib/interfaces.d.ts +48 -4
- package/dist/src/lib/interfaces.d.ts.map +1 -1
- package/dist/src/lib/interfaces.js +89 -28
- package/dist/src/lib/interfaces.js.map +1 -1
- package/dist/src/lib/lib.d.ts +32 -3
- package/dist/src/lib/lib.d.ts.map +1 -1
- package/dist/src/lib/lib.js +57 -2
- package/dist/src/lib/lib.js.map +1 -1
- package/dist/src/lib/project.d.ts +5 -0
- package/dist/src/lib/project.d.ts.map +1 -0
- package/dist/src/lib/project.js +101 -0
- package/dist/src/lib/project.js.map +1 -0
- package/dist/src/lib/scaffolding.d.ts +7 -5
- package/dist/src/lib/scaffolding.d.ts.map +1 -1
- package/dist/src/lib/scaffolding.js +113 -40
- package/dist/src/lib/scaffolding.js.map +1 -1
- package/dist/src/lib/service.d.ts.map +1 -1
- package/dist/src/lib/service.js +496 -587
- package/dist/src/lib/service.js.map +1 -1
- package/dist/src/lib/type-helpers.d.ts +5 -1
- package/dist/src/lib/type-helpers.d.ts.map +1 -1
- package/dist/src/lib/type-helpers.js +32 -3
- package/dist/src/lib/type-helpers.js.map +1 -1
- package/dist/src/lib/utils.d.ts +79 -7
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +971 -36
- package/dist/src/lib/utils.js.map +1 -1
- package/package.json +39 -26
- package/dist/src/lib/testing/index.d.ts +0 -3
- package/dist/src/lib/testing/index.d.ts.map +0 -1
- package/dist/src/lib/testing/index.js +0 -7
- package/dist/src/lib/testing/index.js.map +0 -1
|
@@ -3,7 +3,7 @@ export const GeneratedFileHeader = `// Generated by @typespec/http-server-csharp
|
|
|
3
3
|
// <auto-generated />`;
|
|
4
4
|
export const GeneratedFileHeaderWithNullable = `// Generated by @typespec/http-server-csharp
|
|
5
5
|
// <auto-generated />
|
|
6
|
-
|
|
6
|
+
#nullable enable`;
|
|
7
7
|
export function getSerializationSourceFiles(emitter) {
|
|
8
8
|
const sourceFiles = [];
|
|
9
9
|
sourceFiles.push(new LibrarySourceFile({
|
|
@@ -11,9 +11,9 @@ export function getSerializationSourceFiles(emitter) {
|
|
|
11
11
|
emitter: emitter,
|
|
12
12
|
getContents: getTimeSpanDurationConverter,
|
|
13
13
|
}), new LibrarySourceFile({
|
|
14
|
-
filename: "
|
|
14
|
+
filename: "Base64UrlJsonConverter.cs",
|
|
15
15
|
emitter: emitter,
|
|
16
|
-
getContents:
|
|
16
|
+
getContents: getBase64UrlJsonConverter,
|
|
17
17
|
}), new LibrarySourceFile({
|
|
18
18
|
filename: "UnixEpochDateTimeConverter.cs",
|
|
19
19
|
emitter: emitter,
|
|
@@ -50,6 +50,10 @@ export function getSerializationSourceFiles(emitter) {
|
|
|
50
50
|
filename: "JsonSerializationProvider.cs",
|
|
51
51
|
emitter: emitter,
|
|
52
52
|
getContents: getJsonProvider,
|
|
53
|
+
}), new LibrarySourceFile({
|
|
54
|
+
filename: "HttpServiceException.cs",
|
|
55
|
+
emitter: emitter,
|
|
56
|
+
getContents: getHttpServiceException,
|
|
53
57
|
}));
|
|
54
58
|
return sourceFiles;
|
|
55
59
|
}
|
|
@@ -305,44 +309,52 @@ function getArrayConstraintConverter() {
|
|
|
305
309
|
|
|
306
310
|
public override JsonConverter? CreateConverter(Type typeToConvert)
|
|
307
311
|
{
|
|
308
|
-
|
|
312
|
+
if (typeof(ISet<T>).IsAssignableFrom(typeToConvert))
|
|
313
|
+
{
|
|
314
|
+
return new ConstrainedSetConverter<T>(_minItems, _maxItems);
|
|
315
|
+
}
|
|
316
|
+
else if (typeToConvert.IsArray && typeToConvert.GetElementType() == typeof(T))
|
|
317
|
+
{
|
|
318
|
+
return new ConstrainedStandardArrayConverter<T>(_minItems, _maxItems);
|
|
319
|
+
}
|
|
320
|
+
else
|
|
321
|
+
{
|
|
322
|
+
return new ConstrainedEnumerableConverter<T>(_minItems, _maxItems);
|
|
323
|
+
}
|
|
309
324
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
325
|
}
|
|
313
326
|
|
|
314
|
-
public class
|
|
327
|
+
public abstract class ConstrainedCollectionConverter<T, TCollection> : JsonConverter<TCollection>
|
|
315
328
|
{
|
|
316
|
-
|
|
329
|
+
protected ConstrainedCollectionConverter(int? min, int? max)
|
|
317
330
|
{
|
|
318
331
|
_minItems = min;
|
|
319
332
|
_maxItems = max;
|
|
320
333
|
}
|
|
321
334
|
|
|
322
|
-
|
|
335
|
+
protected int? _minItems, _maxItems;
|
|
323
336
|
public JsonConverter<T>? InnerConverter { get; set; }
|
|
324
337
|
|
|
325
|
-
public virtual Func<
|
|
326
|
-
|
|
338
|
+
public virtual Func<ConstrainedCollectionConverter<T, TCollection>, JsonSerializerOptions, JsonConverter<T>> InnerConverterFactory { get; set; } = ConverterHelpers.GetStandardInnerConverter<T, TCollection>;
|
|
327
339
|
|
|
328
|
-
|
|
340
|
+
protected bool ValidateMin(int count)
|
|
329
341
|
{
|
|
330
342
|
return !_minItems.HasValue || count >= _minItems.Value;
|
|
331
343
|
}
|
|
332
344
|
|
|
333
|
-
|
|
345
|
+
protected bool ValidateMax(int count)
|
|
334
346
|
{
|
|
335
347
|
return !_maxItems.HasValue || count <= _maxItems.Value;
|
|
336
348
|
}
|
|
337
349
|
|
|
338
|
-
|
|
350
|
+
protected void ValidateRange(int count)
|
|
339
351
|
{
|
|
340
352
|
if (!ValidateMax(count) || !ValidateMin(count))
|
|
341
353
|
{
|
|
342
354
|
throw new JsonException($"Number of array elements not in range [{(_minItems.HasValue ? _minItems.Value : 0)}, {(_maxItems.HasValue ? _maxItems.Value : Array.MaxLength)}]");
|
|
343
355
|
}
|
|
344
356
|
}
|
|
345
|
-
public override
|
|
357
|
+
public override TCollection? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
346
358
|
{
|
|
347
359
|
var _innerConverter = InnerConverterFactory(this, options);
|
|
348
360
|
if (reader.TokenType != JsonTokenType.StartArray) { throw new JsonException("Expected start of array"); }
|
|
@@ -357,30 +369,52 @@ function getArrayConstraintConverter() {
|
|
|
357
369
|
count++;
|
|
358
370
|
}
|
|
359
371
|
|
|
360
|
-
return list
|
|
361
|
-
|
|
372
|
+
return ConvertToCollection(list);
|
|
362
373
|
|
|
363
374
|
}
|
|
364
375
|
|
|
365
|
-
public override void Write(Utf8JsonWriter writer,
|
|
376
|
+
public override void Write(Utf8JsonWriter writer, TCollection value, JsonSerializerOptions options)
|
|
366
377
|
{
|
|
367
378
|
var _innerConverter = InnerConverterFactory(this, options);
|
|
368
379
|
writer.WriteStartArray();
|
|
369
|
-
|
|
370
|
-
_innerConverter.Write(writer,
|
|
380
|
+
foreach (var item in GetEnumerable(value))
|
|
381
|
+
_innerConverter.Write(writer, item, options);
|
|
371
382
|
writer.WriteEndArray();
|
|
372
383
|
}
|
|
384
|
+
|
|
385
|
+
protected abstract TCollection ConvertToCollection(List<T> list);
|
|
386
|
+
protected abstract IEnumerable<T> GetEnumerable(TCollection collection);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
public class ConstrainedEnumerableConverter<T> : ConstrainedCollectionConverter<T, IEnumerable<T>>
|
|
390
|
+
{
|
|
391
|
+
public ConstrainedEnumerableConverter(int? min, int? max) : base(min, max) { }
|
|
392
|
+
protected override IEnumerable<T> ConvertToCollection(List<T> list) => list;
|
|
393
|
+
protected override IEnumerable<T> GetEnumerable(IEnumerable<T> collection) => collection;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
public class ConstrainedSetConverter<T> : ConstrainedCollectionConverter<T, ISet<T>>
|
|
397
|
+
{
|
|
398
|
+
public ConstrainedSetConverter(int? min, int? max) : base(min, max) { }
|
|
399
|
+
protected override ISet<T> ConvertToCollection(List<T> list) => new HashSet<T>(list);
|
|
400
|
+
protected override IEnumerable<T> GetEnumerable(ISet<T> collection) => collection;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
public class ConstrainedStandardArrayConverter<T> : ConstrainedCollectionConverter<T, T[]>
|
|
404
|
+
{
|
|
405
|
+
public ConstrainedStandardArrayConverter(int? min, int? max) : base(min, max) { }
|
|
406
|
+
protected override T[] ConvertToCollection(List<T> list) => list.ToArray();
|
|
407
|
+
protected override IEnumerable<T> GetEnumerable(T[] collection) => collection;
|
|
373
408
|
}
|
|
374
409
|
|
|
375
410
|
internal static class ConverterHelpers
|
|
376
411
|
{
|
|
377
|
-
internal static JsonConverter<T> GetStandardInnerConverter<T>(this
|
|
412
|
+
internal static JsonConverter<T> GetStandardInnerConverter<T, TCollection>(this ConstrainedCollectionConverter<T, TCollection> converter, JsonSerializerOptions options)
|
|
378
413
|
{
|
|
379
414
|
if (converter.InnerConverter == null)
|
|
380
415
|
{
|
|
381
416
|
converter.InnerConverter = (JsonConverter<T>)options.GetConverter(typeof(T));
|
|
382
417
|
}
|
|
383
|
-
|
|
384
418
|
return converter.InnerConverter;
|
|
385
419
|
}
|
|
386
420
|
}
|
|
@@ -413,9 +447,23 @@ public class NumericArrayConstraintAttribute<T> : ArrayConstraintAttribute<T> wh
|
|
|
413
447
|
|
|
414
448
|
public override JsonConverter? CreateConverter(Type typeToConvert)
|
|
415
449
|
{
|
|
416
|
-
var result = base.CreateConverter(typeToConvert)
|
|
417
|
-
|
|
418
|
-
|
|
450
|
+
var result = base.CreateConverter(typeToConvert);
|
|
451
|
+
var resultSet = result as ConstrainedSetConverter<T>;
|
|
452
|
+
if (resultSet != null) {
|
|
453
|
+
resultSet.InnerConverterFactory = (c, o) => new NumericJsonConverter<T>(MinValue, MaxValue, MinValueExclusive, MaxValueExclusive, o);
|
|
454
|
+
return resultSet;
|
|
455
|
+
}
|
|
456
|
+
var resultEnumerable = result as ConstrainedEnumerableConverter<T>;
|
|
457
|
+
if (resultEnumerable != null) {
|
|
458
|
+
resultEnumerable.InnerConverterFactory = (c, o) => new NumericJsonConverter<T>(MinValue, MaxValue, MinValueExclusive, MaxValueExclusive, o);
|
|
459
|
+
return resultEnumerable;
|
|
460
|
+
}
|
|
461
|
+
var resultStandardArray = result as ConstrainedStandardArrayConverter<T>;
|
|
462
|
+
if (resultStandardArray != null) {
|
|
463
|
+
resultStandardArray.InnerConverterFactory = (c, o) => new NumericJsonConverter<T>(MinValue, MaxValue, MinValueExclusive, MaxValueExclusive, o);
|
|
464
|
+
return resultStandardArray;
|
|
465
|
+
}
|
|
466
|
+
throw new InvalidOperationException($"Cannot create converter for {typeToConvert} with {this}");
|
|
419
467
|
}
|
|
420
468
|
}
|
|
421
469
|
}`;
|
|
@@ -442,11 +490,27 @@ public class StringArrayConstraintAttribute : ArrayConstraintAttribute<string>
|
|
|
442
490
|
public int MaxItemLength { get { return _maxItemLength.HasValue ? _maxItemLength.Value : 0; } set { _maxItemLength = value; } }
|
|
443
491
|
public string? Pattern { get; set; }
|
|
444
492
|
|
|
445
|
-
override public JsonConverter
|
|
493
|
+
override public JsonConverter? CreateConverter(Type typeToConvert)
|
|
446
494
|
{
|
|
447
|
-
var result = base.CreateConverter(typeToConvert)
|
|
448
|
-
|
|
449
|
-
|
|
495
|
+
var result = base.CreateConverter(typeToConvert);
|
|
496
|
+
var resultSet = result as ConstrainedSetConverter<string>;
|
|
497
|
+
if (resultSet != null) {
|
|
498
|
+
resultSet.InnerConverterFactory = (c, o) => new StringJsonConverter(MinItemLength, MaxItemLength, Pattern, o);
|
|
499
|
+
return resultSet;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
var resultEnumerable = result as ConstrainedEnumerableConverter<string>;
|
|
503
|
+
if (resultEnumerable != null) {
|
|
504
|
+
resultEnumerable.InnerConverterFactory = (c, o) => new StringJsonConverter(MinItemLength, MaxItemLength, Pattern, o);
|
|
505
|
+
return resultEnumerable;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
var resultStandardArray = result as ConstrainedStandardArrayConverter<string>;
|
|
509
|
+
if (resultStandardArray != null) {
|
|
510
|
+
resultStandardArray.InnerConverterFactory = (c, o) => new StringJsonConverter(MinItemLength, MaxItemLength, Pattern, o);
|
|
511
|
+
return resultStandardArray;
|
|
512
|
+
}
|
|
513
|
+
throw new InvalidOperationException($"Cannot create converter for {typeToConvert} with {this}");
|
|
450
514
|
}
|
|
451
515
|
}
|
|
452
516
|
}`;
|
|
@@ -463,7 +527,7 @@ function getTimeSpanDurationConverter() {
|
|
|
463
527
|
/// <summary>
|
|
464
528
|
/// Converts between Json duration and .Net TimeSpan
|
|
465
529
|
/// </summary>
|
|
466
|
-
public class
|
|
530
|
+
public class TimeSpanDurationConverter : JsonConverter<TimeSpan>
|
|
467
531
|
{
|
|
468
532
|
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
469
533
|
{
|
|
@@ -483,7 +547,7 @@ function getTimeSpanDurationConverter() {
|
|
|
483
547
|
}
|
|
484
548
|
`;
|
|
485
549
|
}
|
|
486
|
-
function
|
|
550
|
+
function getBase64UrlJsonConverter() {
|
|
487
551
|
return `${GeneratedFileHeaderWithNullable}
|
|
488
552
|
|
|
489
553
|
using System.Text.Json;
|
|
@@ -667,4 +731,62 @@ namespace TypeSpec.Helpers
|
|
|
667
731
|
}
|
|
668
732
|
`;
|
|
669
733
|
}
|
|
734
|
+
function getHttpServiceException() {
|
|
735
|
+
return `${GeneratedFileHeaderWithNullable}
|
|
736
|
+
|
|
737
|
+
using Microsoft.AspNetCore.Mvc;
|
|
738
|
+
using Microsoft.AspNetCore.Mvc.Filters;
|
|
739
|
+
|
|
740
|
+
namespace TypeSpec.Helpers
|
|
741
|
+
{
|
|
742
|
+
/// <summary>
|
|
743
|
+
/// Represents an HTTP response exception with a status code and optional value.
|
|
744
|
+
/// </summary>
|
|
745
|
+
public class HttpServiceException : Exception
|
|
746
|
+
{
|
|
747
|
+
/// <summary>
|
|
748
|
+
/// Initializes a new instance of the HttpServiceException class.
|
|
749
|
+
/// </summary>
|
|
750
|
+
/// <param name="statusCode">The HTTP status code.</param>
|
|
751
|
+
/// <param name="value">The optional value to include in the response.</param>
|
|
752
|
+
public HttpServiceException(int statusCode, object? value = null, Dictionary<string, string>? headers = null) =>
|
|
753
|
+
(StatusCode, Value, Headers) = (statusCode, value, headers ?? new Dictionary<string, string>());
|
|
754
|
+
|
|
755
|
+
public int StatusCode { get; }
|
|
756
|
+
|
|
757
|
+
public object? Value { get; }
|
|
758
|
+
|
|
759
|
+
public Dictionary<string, string> Headers { get; }
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/// <summary>
|
|
763
|
+
/// An action filter that handles HttpServiceException and converts it to an HTTP response.
|
|
764
|
+
/// </summary>
|
|
765
|
+
public class HttpServiceExceptionFilter : IActionFilter, IOrderedFilter
|
|
766
|
+
{
|
|
767
|
+
public int Order => int.MaxValue - 10;
|
|
768
|
+
|
|
769
|
+
public void OnActionExecuting(ActionExecutingContext context) { }
|
|
770
|
+
|
|
771
|
+
public void OnActionExecuted(ActionExecutedContext context)
|
|
772
|
+
{
|
|
773
|
+
if (context.Exception is HttpServiceException httpServiceException)
|
|
774
|
+
{
|
|
775
|
+
foreach (var header in httpServiceException.Headers)
|
|
776
|
+
{
|
|
777
|
+
context.HttpContext.Response.Headers.Append(header.Key, header.Value.ToString());
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
context.Result = new ObjectResult(httpServiceException.Value)
|
|
781
|
+
{
|
|
782
|
+
StatusCode = httpServiceException.StatusCode
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
context.ExceptionHandled = true;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
`;
|
|
791
|
+
}
|
|
670
792
|
//# sourceMappingURL=boilerplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boilerplate.js","sourceRoot":"","sources":["../../../src/lib/boilerplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,mBAAmB,GAAG;sBACb,CAAC;AACvB,MAAM,CAAC,MAAM,+BAA+B,GAAW;;
|
|
1
|
+
{"version":3,"file":"boilerplate.js","sourceRoot":"","sources":["../../../src/lib/boilerplate.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AssetEmitter } from "@typespec/asset-emitter";
|
|
2
|
+
import { LibrarySourceFile } from "./interfaces.js";
|
|
3
|
+
import { BusinessLogicRegistrations } from "./scaffolding.js";
|
|
4
|
+
export declare function getProjectDocs(emitter: AssetEmitter<string, Record<string, never>>, useSwagger: boolean, registrations?: BusinessLogicRegistrations): LibrarySourceFile[];
|
|
5
|
+
//# sourceMappingURL=doc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../../src/lib/doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAA+B,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE3F,wBAAgB,cAAc,CAC5B,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EACpD,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,0BAA0B,GACzC,iBAAiB,EAAE,CA0BrB"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { LibrarySourceFile } from "./interfaces.js";
|
|
2
|
+
export function getProjectDocs(emitter, useSwagger, registrations) {
|
|
3
|
+
const sourceFiles = [];
|
|
4
|
+
const mocks = registrations === undefined ? [] : [...registrations.entries()].flatMap((e) => e[1]);
|
|
5
|
+
sourceFiles.push(new LibrarySourceFile({
|
|
6
|
+
filename: `README.md`,
|
|
7
|
+
emitter: emitter,
|
|
8
|
+
getContents: () => (mocks.length > 0 ? getMockReadme(mocks) : getNoMockReadme()),
|
|
9
|
+
path: ".",
|
|
10
|
+
}), new LibrarySourceFile({
|
|
11
|
+
filename: `usage.md`,
|
|
12
|
+
emitter: emitter,
|
|
13
|
+
getContents: () => getUsageDoc(),
|
|
14
|
+
path: "docs",
|
|
15
|
+
}), new LibrarySourceFile({
|
|
16
|
+
filename: `emitter.md`,
|
|
17
|
+
emitter: emitter,
|
|
18
|
+
getContents: () => getEmitterDoc(),
|
|
19
|
+
path: "docs",
|
|
20
|
+
}));
|
|
21
|
+
return sourceFiles;
|
|
22
|
+
}
|
|
23
|
+
function getNoMockReadme() {
|
|
24
|
+
return `---
|
|
25
|
+
title: Next Steps
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Next Steps
|
|
29
|
+
|
|
30
|
+
- Use the SwaggerUI endpoint to test out the running service
|
|
31
|
+
- Implement business logic interfaces for your operations
|
|
32
|
+
- Register each of your implementations as part of application startup
|
|
33
|
+
- Update development and production configuration to suit your needs
|
|
34
|
+
|
|
35
|
+
## More Information
|
|
36
|
+
|
|
37
|
+
- See [Code Layout](docs/usage.md) for information about the generated code
|
|
38
|
+
- See [Emitter Usage](docs/emitter.md) for details on how to use the emitter.
|
|
39
|
+
- File issues or provide feedback in [TypeSpec Issues](https://github.com/microsoft/typespec/issues/new/choose)
|
|
40
|
+
- Get information about Typespec on the [TypeSpec website](https://typespec.io)
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
function getUsageDoc() {
|
|
44
|
+
return `---
|
|
45
|
+
title: Generated C-Sharp Overview
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# Generated C-Sharp Overview
|
|
49
|
+
|
|
50
|
+
## Layout
|
|
51
|
+
|
|
52
|
+
The code layout inside the 'generated' folder is as follows:
|
|
53
|
+
|
|
54
|
+
- **generated**
|
|
55
|
+
|
|
56
|
+
- **controllers**: A set of ASP.Net core MVC controllers representing the operations in the spec, one for each interface or namespace with operations
|
|
57
|
+
- **lib**: A set of library files used in implementing generated models and controllers
|
|
58
|
+
- **models**: A set of models representing the data in requests and response
|
|
59
|
+
- **operations**: A set of interfaces called by the controllers, that should be implemented with the business logic for each operation.
|
|
60
|
+
|
|
61
|
+
You should recompile whenever you make changes in your TypeSpec and these files will be replaced inline to reflect the spec changes, without changing any of your hand-written implementation in the project.
|
|
62
|
+
|
|
63
|
+
## Scaffolding
|
|
64
|
+
|
|
65
|
+
If you use the scaffolding cli (hscs) or use the \`--emit-mocks "mocks-and-project-files"\` option on compilation, a
|
|
66
|
+
fully-functional .Net 9 project will be created with mock implementations of your business
|
|
67
|
+
logic, ready to compile and run.
|
|
68
|
+
|
|
69
|
+
The following additional files will be generated. It is expected that you will edit or replace these
|
|
70
|
+
files as you implement your service, so you should only regenerate them when needed.
|
|
71
|
+
To protect from inadvertently changing any edits you may have made to these files,
|
|
72
|
+
these files will be overwritten by the emitter unless you specify the \`--overwrite\` option.
|
|
73
|
+
|
|
74
|
+
- **ServiceProject.csproj**: The project file
|
|
75
|
+
- **Program.cs**: Entry point that sets up the app
|
|
76
|
+
- **appSettings.Development.json**: Configuration settings for the development environment
|
|
77
|
+
- **appSettings.json**: Configuration settings for the production environment
|
|
78
|
+
- **Properties**
|
|
79
|
+
- **launchSettings.json**: Launch configurations for the service (including local ports)
|
|
80
|
+
- **mocks**: Simple implementations of business logic interfaces that return simple responses.
|
|
81
|
+
this allows testing your service out before writing any implementation code.
|
|
82
|
+
|
|
83
|
+
- **MockRegistration.cs**: Called from the Program.cs startup, registers each of the business
|
|
84
|
+
logic implementations in the dependency injection container.
|
|
85
|
+
- **IInitializer.cs**: Interface used in the mocks to create responses.
|
|
86
|
+
- **Initializer.cs**: Implementation of the interface to create mock responses.
|
|
87
|
+
|
|
88
|
+
## SwaggerUI
|
|
89
|
+
|
|
90
|
+
If you include the \`@typespec/openapi3\` emitter in your typespec project, you can include a
|
|
91
|
+
SwaggerUI endpoint in the generated service using the \`--use-swaggerui\` option. This endpoint
|
|
92
|
+
provides a visual representation of operations and provides a web GUI client connected to the service that you can use right away to try out service operations.
|
|
93
|
+
|
|
94
|
+
## How Components Work Together
|
|
95
|
+
|
|
96
|
+
### Controllers
|
|
97
|
+
|
|
98
|
+
The generated controllers automatically listen at the routes you specified in TypeSpec. Controllers perform validation of input requests, call your implementation of business logic interfaces to perform the operation, and return the appropriate Http response.
|
|
99
|
+
|
|
100
|
+
### Business Logic Interfaces
|
|
101
|
+
|
|
102
|
+
You must implement business loginc interfaces to perform the work of each operation. There is one
|
|
103
|
+
business logic interface for each \`interface\` type in your spec, or for each namespace that contain operations. Business logic can assume that input types meet the constraints specified in TypeSpec and are responsible for returning the response type for the operation.
|
|
104
|
+
|
|
105
|
+
You can use the \`--emit-mocks\` option to emit mock implementations of your business logic, these mocks demonstrate a simple implementation that returns responses that match the response type in TypeSpec. They also show how to use \`IHttpContextAccessor\` to access additional details of the Http request and response.
|
|
106
|
+
|
|
107
|
+
### Discovery using the ASP.Net Core Dependency Injection Container
|
|
108
|
+
|
|
109
|
+
The Controllers find your business logic implementation through the ASP.Net dependency injection container. At server start, you register each of your implementations with the dependency injection container and they will automatically be instantiated and used by the controllers.
|
|
110
|
+
|
|
111
|
+
If you use the \`--emit-mocks\` option, sample code registering mock implementations is emitted to \`mocks/MockRegistration.cs\`.
|
|
112
|
+
|
|
113
|
+
### Models
|
|
114
|
+
|
|
115
|
+
Model classes represent the data passed in Http requests and response and the data that passes from the front end controllers to your business logic.
|
|
116
|
+
|
|
117
|
+
Models are partial, so you can add additional members for internal usage as needed by putting a partial class definition with additional members outside the \`generated\` folder in your project.
|
|
118
|
+
|
|
119
|
+
### Next Steps
|
|
120
|
+
|
|
121
|
+
After successful generation, you should:
|
|
122
|
+
|
|
123
|
+
- Use the SwaggerUI endpoint to test out the running service
|
|
124
|
+
- Implement the business logic interfaces for your operations
|
|
125
|
+
- Update MockRegistration.cs, or register each of your interfaces as part of application startup
|
|
126
|
+
- Update configuration to suit your needs
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
function getEmitterDoc() {
|
|
130
|
+
return `---
|
|
131
|
+
title: "Emitter usage"
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
# Emitter Usage
|
|
135
|
+
|
|
136
|
+
1. Via the command line
|
|
137
|
+
|
|
138
|
+
\`\`\`bash
|
|
139
|
+
tsp compile . --emit=@typespec/http-server-csharp
|
|
140
|
+
\`\`\`
|
|
141
|
+
|
|
142
|
+
2. Via the config
|
|
143
|
+
|
|
144
|
+
\`\`\`yaml
|
|
145
|
+
emit:
|
|
146
|
+
- "@typespec/http-server-csharp"
|
|
147
|
+
\`\`\`
|
|
148
|
+
|
|
149
|
+
The config can be extended with options as follows:
|
|
150
|
+
|
|
151
|
+
\`\`\`yaml
|
|
152
|
+
emit:
|
|
153
|
+
- "@typespec/http-server-csharp"
|
|
154
|
+
options:
|
|
155
|
+
"@typespec/http-server-csharp":
|
|
156
|
+
option: value
|
|
157
|
+
\`\`\`
|
|
158
|
+
|
|
159
|
+
## Emitter options
|
|
160
|
+
|
|
161
|
+
### \`skip-format\`
|
|
162
|
+
|
|
163
|
+
**Type:** \`boolean\`
|
|
164
|
+
|
|
165
|
+
Skips formatting of generated C# Types. By default, C# files are formatted using 'dotnet format'.
|
|
166
|
+
|
|
167
|
+
### \`output-type\`
|
|
168
|
+
|
|
169
|
+
**Type:** \`"models" | "all"\`
|
|
170
|
+
|
|
171
|
+
Chooses which service artifacts to emit. choices include 'models' or 'all' artifacts.
|
|
172
|
+
|
|
173
|
+
### \`emit-mocks\`
|
|
174
|
+
|
|
175
|
+
**Type:** \`"mocks-and-project-files" | "mocks-only" | "none"\`
|
|
176
|
+
|
|
177
|
+
Emits mock implementations of business logic, setup code, and project files enabling the service to respond to requests before a real implementation is provided
|
|
178
|
+
|
|
179
|
+
### \`use-swaggerui\`
|
|
180
|
+
|
|
181
|
+
**Type:** \`boolean\`
|
|
182
|
+
|
|
183
|
+
Configure a Swagger UI endpoint in the development configuration
|
|
184
|
+
|
|
185
|
+
### \`openapi-path\`
|
|
186
|
+
|
|
187
|
+
**Type:** \`string\`
|
|
188
|
+
|
|
189
|
+
Use openapi at the given path for generating SwaggerUI endpoints. By default, this will be 'openapi/openapi.yaml' if the 'use-swaggerui' option is enabled.
|
|
190
|
+
|
|
191
|
+
### \`overwrite\`
|
|
192
|
+
|
|
193
|
+
**Type:** \`boolean\`
|
|
194
|
+
|
|
195
|
+
When generating mock files, setup code, and project files overwrite any existing files with the same name.
|
|
196
|
+
|
|
197
|
+
### \`project-name\`
|
|
198
|
+
|
|
199
|
+
**Type:** \`string\`
|
|
200
|
+
|
|
201
|
+
The name of the generated project.
|
|
202
|
+
|
|
203
|
+
### \`http-port\`
|
|
204
|
+
|
|
205
|
+
**Type:** \`number\`
|
|
206
|
+
|
|
207
|
+
The service http port when hosting the project locally.
|
|
208
|
+
|
|
209
|
+
### \`https-port\`
|
|
210
|
+
|
|
211
|
+
**Type:** \`number\`
|
|
212
|
+
|
|
213
|
+
The service https port when hosting the project locally.
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
function getMockReadme(mocks) {
|
|
217
|
+
return `---
|
|
218
|
+
title: Next Steps
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
# Next Steps
|
|
222
|
+
|
|
223
|
+
- Use the SwaggerUI endpoint to test out the running service
|
|
224
|
+
- Update business logic mocks with real business logic
|
|
225
|
+
${mocks.flatMap((m) => ` - \`mocks/${m.className}.cs\``).join("\n")}
|
|
226
|
+
- Update \`mocks/MockRegistration.cs\` if you update the constructor of business logic implementations.
|
|
227
|
+
- Update development and production configuration to suit your needs
|
|
228
|
+
|
|
229
|
+
## More Information
|
|
230
|
+
|
|
231
|
+
- See [Code Layout](docs/usage.md) for information about the generated code
|
|
232
|
+
- See [Emitter Usage](docs/emitter.md) for details on how to use the emitter.
|
|
233
|
+
- File issues or provide feedback in [TypeSpec Issues](https://github.com/microsoft/typespec/issues/new/choose)
|
|
234
|
+
- Get information about Typespec on the [TypeSpec website](https://typespec.io)
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../../src/lib/doc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,UAAU,cAAc,CAC5B,OAAoD,EACpD,UAAmB,EACnB,aAA0C;IAE1C,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,MAAM,KAAK,GACT,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,WAAW,CAAC,IAAI,CACd,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;QAChF,IAAI,EAAE,GAAG;KACV,CAAC,EACF,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;QAChC,IAAI,EAAE,MAAM;KACb,CAAC,EACF,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE;QAClC,IAAI,EAAE,MAAM;KACb,CAAC,CACH,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AACD,SAAS,eAAe;IACtB,OAAO;;;;;;;;;;;;;;;;;CAiBR,CAAC;AACF,CAAC;AAED,SAAS,WAAW;IAClB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFR,CAAC;AACF,CAAC;AAED,SAAS,aAAa;IACpB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFR,CAAC;AACF,CAAC;AACD,SAAS,aAAa,CAAC,KAAoC;IACzD,OAAO;;;;;;;;EAQP,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;CAUnE,CAAC;AACF,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AssetEmitter, Context, EmittedSourceFile, EmitterOutput, Scope, SourceFile } from "@typespec/asset-emitter";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
import { HttpStatusCodeRange } from "@typespec/http";
|
|
4
|
+
import { HttpRequestParameterKind } from "@typespec/http/experimental/typekit";
|
|
5
|
+
import { CSharpServiceEmitterOptions } from "./lib.js";
|
|
4
6
|
export declare const HelperNamespace: string;
|
|
5
7
|
export interface CSharpTypeMetadata {
|
|
6
8
|
name: string;
|
|
@@ -17,17 +19,45 @@ export declare class CSharpType implements CSharpTypeMetadata {
|
|
|
17
19
|
isBuiltIn: boolean;
|
|
18
20
|
isValueType: boolean;
|
|
19
21
|
isNullable: boolean;
|
|
22
|
+
isClass: boolean;
|
|
23
|
+
isCollection: boolean;
|
|
20
24
|
constructor(input: {
|
|
21
25
|
name: string;
|
|
22
26
|
namespace: string;
|
|
23
27
|
isBuiltIn?: boolean;
|
|
24
28
|
isValueType?: boolean;
|
|
25
29
|
isNullable?: boolean;
|
|
30
|
+
isClass?: boolean;
|
|
31
|
+
isCollection?: boolean;
|
|
26
32
|
});
|
|
27
33
|
isNamespaceInScope(scope?: Scope<string>, visited?: Set<Scope<string>>): boolean;
|
|
28
34
|
getTypeReference(scope?: Scope<string>): string;
|
|
29
35
|
equals(other: CSharpType | undefined): boolean;
|
|
30
36
|
}
|
|
37
|
+
export declare function checkOrAddNamespaceToScope(ns: string, scope?: Scope<string>, visited?: Set<Scope<string>>): boolean;
|
|
38
|
+
export declare enum CollectionType {
|
|
39
|
+
ISet = "ISet",
|
|
40
|
+
ICollection = "ICollection",
|
|
41
|
+
IEnumerable = "IEnumerable",
|
|
42
|
+
Array = "[]"
|
|
43
|
+
}
|
|
44
|
+
export declare function resolveCollectionType(option?: string): CollectionType;
|
|
45
|
+
export declare class CSharpCollectionType extends CSharpType {
|
|
46
|
+
collectionType: CollectionType;
|
|
47
|
+
itemTypeName: string;
|
|
48
|
+
static readonly implementationType: Record<CollectionType, string>;
|
|
49
|
+
constructor(csharpType: {
|
|
50
|
+
name: string;
|
|
51
|
+
namespace: string;
|
|
52
|
+
isBuiltIn?: boolean;
|
|
53
|
+
isValueType?: boolean;
|
|
54
|
+
isNullable?: boolean;
|
|
55
|
+
isClass?: boolean;
|
|
56
|
+
isCollection?: boolean;
|
|
57
|
+
}, collectionType: CollectionType, itemTypeName: string);
|
|
58
|
+
getTypeReference(scope?: Scope<string> | undefined): string;
|
|
59
|
+
getImplementationType(): string;
|
|
60
|
+
}
|
|
31
61
|
export declare abstract class CSharpValue {
|
|
32
62
|
value?: any;
|
|
33
63
|
abstract emitValue(scope?: Scope<string>): string;
|
|
@@ -99,7 +129,7 @@ export declare class CSharpController extends CSharpDeclaration {
|
|
|
99
129
|
getDeclaration(scope: Scope<string>): EmitterOutput<string>;
|
|
100
130
|
}
|
|
101
131
|
export interface ControllerContext extends Context {
|
|
102
|
-
|
|
132
|
+
namespace: string;
|
|
103
133
|
resourceName: string;
|
|
104
134
|
resourceType?: Model;
|
|
105
135
|
scope: Scope<string>;
|
|
@@ -128,12 +158,26 @@ export declare class LibrarySourceFile {
|
|
|
128
158
|
constructor(params: {
|
|
129
159
|
filename: string;
|
|
130
160
|
getContents: () => string;
|
|
131
|
-
emitter: AssetEmitter<string,
|
|
161
|
+
emitter: AssetEmitter<string, CSharpServiceEmitterOptions>;
|
|
132
162
|
path?: string;
|
|
163
|
+
conditional?: boolean;
|
|
133
164
|
});
|
|
165
|
+
conditional: boolean;
|
|
134
166
|
filename: string;
|
|
135
167
|
source: SourceFile<string>;
|
|
136
168
|
emitted: EmittedSourceFile;
|
|
137
169
|
path: string;
|
|
138
170
|
}
|
|
171
|
+
export interface CSharpOperationParameter {
|
|
172
|
+
name: string;
|
|
173
|
+
typeName: EmitterOutput<string>;
|
|
174
|
+
optional: boolean;
|
|
175
|
+
httpParameterKind: HttpRequestParameterKind;
|
|
176
|
+
httpParameterName?: string;
|
|
177
|
+
callName: string;
|
|
178
|
+
isExplicitBody: boolean;
|
|
179
|
+
nullable: boolean;
|
|
180
|
+
operationKind: "Http" | "BusinessLogic" | "All";
|
|
181
|
+
defaultValue?: string | boolean;
|
|
182
|
+
}
|
|
139
183
|
//# sourceMappingURL=interfaces.d.ts.map
|