Skip to content

Commit

Permalink
/
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzie committed Jan 29, 2024
1 parent 43c071a commit d111d9c
Show file tree
Hide file tree
Showing 72 changed files with 108 additions and 1,380 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Go API client for topica
# Go API client for topicaclient

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Expand All @@ -21,7 +21,7 @@ go get golang.org/x/net/context
Put the package under your project folder and add the following in import:

```go
import topica "github.com/GIT_USER_ID/GIT_REPO_ID"
import topicaclient "github.com/GIT_USER_ID/GIT_REPO_ID"
```

To use a proxy, set the environment variable `HTTP_PROXY`:
Expand All @@ -36,18 +36,18 @@ Default configuration comes with `Servers` field that contains server objects as

### Select Server Configuration

For using other server than the one defined on index 0 set context value `topica.ContextServerIndex` of type `int`.
For using other server than the one defined on index 0 set context value `topicaclient.ContextServerIndex` of type `int`.

```go
ctx := context.WithValue(context.Background(), topica.ContextServerIndex, 1)
ctx := context.WithValue(context.Background(), topicaclient.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `topica.ContextServerVariables` of type `map[string]string`.
Templated server URL is formatted using default variables from configuration or from context value `topicaclient.ContextServerVariables` of type `map[string]string`.

```go
ctx := context.WithValue(context.Background(), topica.ContextServerVariables, map[string]string{
ctx := context.WithValue(context.Background(), topicaclient.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```
Expand All @@ -58,13 +58,13 @@ Note, enum values are always validated and all unused variables are silently ign

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `topica.ContextOperationServerIndices` and `topica.ContextOperationServerVariables` context maps.
Similar rules for overriding default operation server index and variables applies by using `topicaclient.ContextOperationServerIndices` and `topicaclient.ContextOperationServerVariables` context maps.

```go
ctx := context.WithValue(context.Background(), topica.ContextOperationServerIndices, map[string]int{
ctx := context.WithValue(context.Background(), topicaclient.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), topica.ContextOperationServerVariables, map[string]map[string]string{
ctx = context.WithValue(context.Background(), topicaclient.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
Expand Down Expand Up @@ -102,7 +102,7 @@ Authentication schemes defined for the API:
Example

```go
auth := context.WithValue(context.Background(), topica.ContextBasicAuth, topica.BasicAuth{
auth := context.WithValue(context.Background(), topicaclient.ContextBasicAuth, topicaclient.BasicAuth{
UserName: "username",
Password: "password",
})
Expand All @@ -122,8 +122,8 @@ Example
```go
auth := context.WithValue(
context.Background(),
topica.ContextAPIKeys,
map[string]topica.APIKey{
topicaclient.ContextAPIKeys,
map[string]topicaclient.APIKey{
"X-API-KEY": {Key: "API_KEY_STRING"},
},
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "topica"
name = "topica_client"
version = "0.0.1"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rust API client for topica
# Rust API client for topica_client

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

Expand All @@ -13,10 +13,10 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

## Installation

Put the package under your project folder in a directory named `topica` and add the following to `Cargo.toml` under `[dependencies]`:
Put the package under your project folder in a directory named `topica_client` and add the following to `Cargo.toml` under `[dependencies]`:

```
topica = { path = "./topica" }
topica_client = { path = "./topica_client" }
```

## Documentation for API Endpoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [email protected]
## @topica/client@0.0.1

This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

Expand Down Expand Up @@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co
_published:_

```
npm install [email protected] --save
npm install @topica/client@0.0.1 --save
```

_unPublished (not recommended):_
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "topica",
"name": "@topica/client",
"version": "0.0.1",
"description": "OpenAPI client for topica",
"description": "OpenAPI client for @topica/client",
"author": "OpenAPI-Generator",
"repository": {
"type": "git",
Expand Down
28 changes: 28 additions & 0 deletions Source/Dockerfile.UI
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:20-alpine as setup

RUN npm install -g pnpm
WORKDIR /
COPY ./Clients/TypeScript ./Clients/TypeScript

WORKDIR /src
COPY ./Topica.UI .

WORKDIR /Clients/TypeScript/Topica.Client
RUN pnpm i

FROM setup as install
WORKDIR /src
RUN pnpm clean
RUN pnpm i --frozen-lockfile

FROM install as Build
WORKDIR /src
RUN pnpm build

FROM node:20-alpine as App
RUN npm i -g serve
COPY --from=Build src/dist ./dist

EXPOSE 80

CMD [ "serve", "-s", "dist", "-l", "80" ]
13 changes: 7 additions & 6 deletions Source/Scripts/GenerateCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { execute } from "./Execute";

const tempFolder = path.join(__dirname, "../temp");
const version = fse.readFileSync(path.join(__dirname, "../version.txt"));
const appName = "topica";

const appName = "Topica";
const lowered = "Topica".toLowerCase();
if (fse.existsSync(tempFolder)) fse.removeSync(tempFolder);
fse.mkdirSync(tempFolder);
collectSwaggerFoldersIntoTemp([
Expand All @@ -20,12 +20,13 @@ if (fse.existsSync(CodeGenPath))
if (!fse.existsSync(CodeGenPath))
fse.mkdirsSync(CodeGenPath);

const swaggerFile = `temp/Swagger/${appName}.Server/Swagger.json`
execute(`npx @openapitools/openapi-generator-cli version-manager set 7.2.0`)
execute(`npx @openapitools/openapi-generator-cli generate -i temp/Swagger/${appName}.Server/v1/Swagger.json -g rust -o ${CodeGenPath}/v1/Rust/${appName}.Client --additional-properties=packageVersion=${version},packageName=${appName}`)
execute(`npx @openapitools/openapi-generator-cli generate -i temp/Swagger/${appName}.Server/v1/Swagger.json -g typescript-fetch -o ${CodeGenPath}/v1/TypeScript/${appName}.Client -p npmName=${appName} --additional-properties=npmVersion=${version},stringEnums=true`)
execute(`npx @openapitools/openapi-generator-cli generate -i temp/Swagger/${appName}.Server/v1/Swagger.json -g go -o ${CodeGenPath}/v1/Go/${appName}.Client --additional-properties=enumClassPrefix=true,packageVersion=${version},packageName=${appName}`)
execute(`npx @openapitools/openapi-generator-cli generate -i ${swaggerFile} -g rust -o ${CodeGenPath}/Rust/${appName}.Client --additional-properties=packageVersion=${version},packageName=${lowered}_client`)
execute(`npx @openapitools/openapi-generator-cli generate -i ${swaggerFile} -g typescript-fetch -o ${CodeGenPath}/TypeScript/${appName}.Client -p npmName=@${lowered}/client --additional-properties=npmVersion=${version},stringEnums=true`)
execute(`npx @openapitools/openapi-generator-cli generate -i ${swaggerFile} -g go -o ${CodeGenPath}/Go/${appName}.Client --additional-properties=enumClassPrefix=true,packageVersion=${version},packageName=${lowered}client`)

execute(`cd ${CodeGenPath}/v1/TypeScript/${appName}.Client && npm i && npm run build `)
execute(`cd ${CodeGenPath}/TypeScript/${appName}.Client && npm i && npm run build`)

function collectSwaggerFoldersIntoTemp(swaggerPaths: string[]) {
swaggerPaths.forEach((e) => {
Expand Down
2 changes: 1 addition & 1 deletion Source/Topica.Server/Topica.Server/Topica.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
</Content>
</ItemGroup>
<Target Name="OpenAPI" AfterTargets="Build" Condition="$(Configuration)=='Debug'">
<Exec Command="dotnet swagger tofile --output Swagger\v1\Swagger.json $(OutputPath)$(AssemblyName).dll v1" WorkingDirectory="$(ProjectDir)" />
<Exec Command="dotnet swagger tofile --output Swagger\Swagger.json $(OutputPath)$(AssemblyName).dll v1" WorkingDirectory="$(ProjectDir)" />
</Target>
</Project>
Empty file added Source/Topica.UI/.npmrc
Empty file.
5 changes: 3 additions & 2 deletions Source/Topica.UI/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "events-ui",
"name": "topica-ui",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -13,10 +13,11 @@
"dependencies": {
"@ant-design/icons": "^5.2.6",
"@auth-kit/react-router": "3.0.2-alpha.19",
"@topica/client": "file://../Clients/v1/TypeScript/Topica.Client",
"@topica/client": "file://../Clients/TypeScript/Topica.Client",
"@uidotdev/usehooks": "^2.4.1",
"ahooks": "^3.7.9",
"antd": "^5.13.3",
"jwt-decode": "^4.0.0",
"react": "^18.2.0",
"react-auth-kit": "^3.0.1",
"react-dom": "^18.2.0",
Expand Down
18 changes: 13 additions & 5 deletions Source/Topica.UI/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added Source/Topica.UI/src/config.js
Empty file.
Loading

0 comments on commit d111d9c

Please sign in to comment.