Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support generating required fields as not optional in TS. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d96d6f5
generate error sets (#57)
heymb Sep 18, 2023
80e741f
Publish 2.9.0.
Sep 18, 2023
04b7493
Make failed expectations more clear in conformanceApiTests.ts.
mitchknife Dec 15, 2023
b6f838e
Clean up conformance test runner.
mitchknife Dec 15, 2023
c11db89
Add simple working fastify app for conformance tests.
mitchknife Dec 15, 2023
b4f1516
Add "hand rolled" ConformanceApi plugin.
mitchknife Dec 15, 2023
724ddca
Generate fastify plugin shell.
mitchknife Dec 15, 2023
ae6f3b9
Fill out codegen for fastify plugin.
mitchknife Dec 16, 2023
0901688
Generate separate copy of types for fastify plugin.
mitchknife Dec 16, 2023
862cc03
Consolidate duplicate code into local functions.
mitchknife Dec 16, 2023
9175554
Delete handRolledPlugin.ts
mitchknife Dec 16, 2023
a7a77ef
Clean up plain js support.
mitchknife Dec 16, 2023
dd18f5a
Restructure conformance folder structure.
mitchknife Dec 17, 2023
6470f1d
Only generate fastify plugin when option is supplied.
mitchknife Dec 17, 2023
da68074
Validate ConformanceTests.json before running tests.
mitchknife Dec 18, 2023
26b39c1
Support raw http requests in conformance tests.
mitchknife Dec 18, 2023
c576130
Support case insensitive querystring keys in fastify plugin.
mitchknife Dec 18, 2023
d7bfd59
Enable case insensitve routing for fastify conformance servers.
mitchknife Dec 18, 2023
6102789
Add service error handling support to fastify plugin.
mitchknife Dec 18, 2023
c625c24
Add clarifying doc comments.
mitchknife Dec 18, 2023
0c72936
Run conformance js and ts fastify plugins together.
mitchknife Dec 19, 2023
d17ad41
Merge pull request #59 from mitchknife/fastify
mitchknife Dec 29, 2023
35be5b5
Add JsonSchema support to fastify plugin.
mitchknife Dec 30, 2023
a00bbc0
Switch on `ServiceTypeKind`
mitchknife Jan 1, 2024
51f5c1f
Assume non-null value from `GetFieldType`.
mitchknife Jan 1, 2024
580c68b
Don't use interpolated strings to prevent analysis warning.
mitchknife Jan 1, 2024
fff1953
Merge pull request #60 from mitchknife/fastify-json-schema
mitchknife Jan 2, 2024
e36eb2d
Miscellaneous updates.
ejball Jan 20, 2024
035032d
Miscellaneous updates.
ejball Mar 22, 2024
699dfaf
Don't align raw literal string content.
ejball Mar 23, 2024
ba84bb9
Allow explicit docs publish.
ejball Mar 23, 2024
f590b40
Update dependencies.
ejball Mar 23, 2024
a82d484
Fix docs publish.
ejball Mar 26, 2024
e781147
Update dependency.
ejball May 15, 2024
4a90067
Install .NET 6.0 and 8.0 SDKs.
ejball May 17, 2024
761d526
Merge template/faithlife-build.
ejball May 17, 2024
de9699f
Add file name suffix option (#61)
victorbush May 17, 2024
adefd41
Publish 2.10.0 (#62)
victorbush May 20, 2024
2b22cfa
Documentation updated.
FacilityApiBot May 20, 2024
e1a282a
Fix types file references when using file-name-suffix option . (#63)
victorbush May 21, 2024
6a63fb0
Publish 2.10.1. (#64)
victorbush May 21, 2024
4928a03
Enable use of external enums as URI and header params. (#65)
victorbush Jun 26, 2024
9a0260e
Publish 2.11.0. (#66)
victorbush Jun 26, 2024
0df8f2e
Ignore events for now.
ejball Jul 4, 2024
86206e7
Publish 2.11.1.
ejball Jul 4, 2024
6365737
Merge pull request #67 from ejball/events
ejball Jul 4, 2024
1824ab0
Documentation updated.
FacilityApiBot Jul 4, 2024
6cf4974
Add tests for current TS output of DTOs with "optional" and required …
heymb Aug 5, 2024
a085f10
Support generating required fields as not optional in TS
Aug 2, 2024
ff4f6ea
Run codegen since required now is not optional
Aug 2, 2024
499aa47
Update version number and release notes per contributing docs since g…
Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ resharper_string_literal_typo_highlighting = none
indent_size = 4
indent_style = tab

[Directory.Packages.props]
insert_final_newline = false

[dotnet-tools.json]
insert_final_newline = false

Expand Down Expand Up @@ -91,6 +94,7 @@ csharp_style_prefer_local_over_anonymous_function = true : suggestion
csharp_style_prefer_not_pattern = true : suggestion
csharp_style_prefer_null_check_over_type_check = true : suggestion
csharp_style_prefer_pattern_matching = true : suggestion
csharp_style_prefer_primary_constructors = true : suggestion
csharp_style_prefer_range_operator = true : suggestion
csharp_style_prefer_switch_expression = true : suggestion
csharp_style_prefer_tuple_swap = true : warning
Expand Down Expand Up @@ -207,6 +211,7 @@ dotnet_diagnostic.IDE0160.severity = suggestion
dotnet_diagnostic.IDE0161.severity = suggestion
dotnet_diagnostic.IDE0170.severity = suggestion
dotnet_diagnostic.IDE0180.severity = warning
dotnet_diagnostic.IDE0290.severity = suggestion
dotnet_diagnostic.IDE1005.severity = suggestion
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1003.severity = none
Expand Down Expand Up @@ -330,6 +335,7 @@ resharper_arrange_missing_parentheses_highlighting = hint
resharper_arrange_trailing_comma_in_multiline_lists_highlighting = warning
resharper_comment_typo_highlighting = none
resharper_compare_of_floats_by_equality_operator_highlighting = suggestion
resharper_convert_to_primary_constructor_highlighting = hint
resharper_csharp_align_first_arg_by_paren = false
resharper_csharp_align_linq_query = false
resharper_csharp_align_multiline_argument = false
Expand All @@ -351,6 +357,7 @@ resharper_csharp_indent_anonymous_method_block = false
resharper_csharp_indent_nested_for_stmt = true
resharper_csharp_indent_nested_foreach_stmt = true
resharper_csharp_indent_nested_while_stmt = true
resharper_csharp_indent_raw_literal_string = indent
resharper_csharp_int_align = false
resharper_csharp_keep_existing_arrangement = true
resharper_csharp_nested_ternary_style = simple_wrap
Expand Down
32 changes: 15 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
name: Build

on:
workflow_dispatch:
push:
paths-ignore:
- '*.md'
- 'docs/**'
branches:
- 'master'
tags-ignore:
- '**'
branches: [master]
tags-ignore: ['**']
pull_request:
paths-ignore:
- '*.md'
- 'docs/**'
workflow_dispatch:

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

defaults:
run:
shell: pwsh

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
fetch-depth: 0 # required to publish docs
- name: Restore
run: .\build.ps1 restore
- name: Build
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish Docs

on:
workflow_dispatch:

env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

defaults:
run:
shell: pwsh

jobs:
publish-docs:
runs-on: windows-latest
steps:
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0 # required to publish docs
- name: Publish Docs
env:
BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }}
run: .\build.ps1 publish --no-test --trigger publish-docs
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.vs/
.idea/
artifacts/
bin/
obj/
release/
.vs/
.idea/
Thumbs.db

*.cache
*.user
*.userprefs
*.log
*.ncrunchproject
*.ncrunchsolution
*.user
launchSettings.json
nCrunchTemp*
_ReSharper*
.DS_Store
launchSettings.json
24 changes: 10 additions & 14 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project>

<PropertyGroup>
<VersionPrefix>2.8.0</VersionPrefix>
<LangVersion>11.0</LangVersion>
<VersionPrefix>3.0.0</VersionPrefix>
<PackageValidationBaselineVersion>2.8.0</PackageValidationBaselineVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1591;1998;NU1507;NU5105</NoWarn>
<NeutralLanguage>en-US</NeutralLanguage>
<NoWarn>$(NoWarn);1591;1998;NU5105</NoWarn>
<DebugType>embedded</DebugType>
<GitHubOrganization>FacilityApi</GitHubOrganization>
<RepositoryName>FacilityJavaScript</RepositoryName>
Expand All @@ -20,26 +21,21 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest-all</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
<SelfContained>false</SelfContained>
<UseArtifactsOutput>true</UseArtifactsOutput>
<EnableStrictModeForCompatibleFrameworksInPackageValidation>true</EnableStrictModeForCompatibleFrameworksInPackageValidation>
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
<DisablePackageBaselineValidation Condition=" $(PackageValidationBaselineVersion) == $(VersionPrefix) or $(PackageValidationBaselineVersion) == '0.0.0' ">true</DisablePackageBaselineValidation>
</PropertyGroup>

<PropertyGroup Condition=" '$(BuildNumber)' != '' ">
<AssemblyVersion>$(VersionPrefix).$(BuildNumber)</AssemblyVersion>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup>
<FacilityVersion>2.11.0</FacilityVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Faithlife.Analyzers" Version="1.4.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Facility.CodeGen.Console" Version="2.14.0" />
<PackageVersion Include="Facility.Definition" Version="2.14.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="XmlDocMarkdown.Core" Version="2.9.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Faithlife.Analyzers" Version="1.5.0" />
<GlobalPackageReference Include="NUnit.Analyzers" Version="4.2.0" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions FacilityJavaScript.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
dotnet-tools.json = dotnet-tools.json
example\ExampleApi.fsd = example\ExampleApi.fsd
Directory.Packages.props = Directory.Packages.props
global.json = global.json
LICENSE = LICENSE
nuget.config = nuget.config
ts\package.json = ts\package.json
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright 2022 Ed Ball
Copyright 2024 Ed Ball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ fsdgenjs | A tool that generates JavaScript or TypeScript for a Facility Service
Facility.CodeGen.JavaScript | A library that generates JavaScript or TypeScript for a Facility Service Definition. | [![NuGet](https://img.shields.io/nuget/v/Facility.CodeGen.JavaScript.svg)](https://www.nuget.org/packages/Facility.CodeGen.JavaScript)

[Documentation](https://facilityapi.github.io/) | [Release Notes](https://github.com/FacilityApi/FacilityJavaScript/blob/master/ReleaseNotes.md) | [Contributing](https://github.com/FacilityApi/FacilityJavaScript/blob/master/CONTRIBUTING.md)

## Conformance

To run conformance tests, first start one of the conformance servers from within the `/conformance` folder:

```
npm run fastify
```

Then run the conformance tool against the running service.

```
npm run test
```
25 changes: 25 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

These are the NuGet package releases. See also [npm Release Notes](ReleaseNotesNpm.md).

## 3.0.0

* Support required fields as not optional in TypeScript.

## 2.11.1

* Ignore events for now.

## 2.11.0

* Enable use of external enumerations as URI and header request parameters.

## 2.10.1

* Fix TypeScript file name references when using `file-name-suffix` generator setting.

## 2.10.0

* Add `file-name-suffix` generator setting.
* Support generating Fastify plugins.

## 2.9.0

* Generate error sets in TypeScript.

## 2.8.0

* Support `datetime`.
Expand Down
11 changes: 3 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
$ErrorActionPreference = 'Stop'
Push-Location $PSScriptRoot
try {
if (-not (Test-Path ./tools/bin/Build) -or
(Get-ChildItem ./tools/Build/* | Measure-Object LastWriteTime -Maximum).Maximum -gt
(Get-ChildItem ./tools/bin/Build/* | Measure-Object LastWriteTime -Maximum).Maximum) {
if (Test-Path ./tools/bin/Build) { Remove-Item ./tools/bin/Build -Recurse }
dotnet publish ./tools/Build/Build.csproj --output ./tools/bin/Build --nologo --verbosity quiet
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
dotnet ./tools/bin/Build/Build.dll $args
dotnet publish ./tools/Build/Build.csproj --artifacts-path ./artifacts --nologo --verbosity quiet
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet ./artifacts/publish/Build/release/Build.dll $args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
finally {
Expand Down
2 changes: 2 additions & 0 deletions conformance/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
9 changes: 9 additions & 0 deletions conformance/ConformanceApi.fsd
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ service ConformanceApi
[http(from: body, type: "application/x-output")] content: bytes;
}

[http(method: GET)]
event fibonacci
{
count: int32!;
}:
{
value: int32!;
}

data Any
{
string: string;
Expand Down
Loading
Loading