Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/build-typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build typescript client library
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout your code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# Use the action to generate a server library
- name: Generate ASPNET Core server
uses: openapi-generators/openapitools-generator-action@b729d184e6b3459572c37c0e37f88a832e69b552 #v1.5.0
with:
generator: typescript-fetch
openapi-file: PxAPI-2.yml
config-file: typescript-fetch-generator-config.yml
generator-tag: v7.11.0
command-args: -o ./typescript-fetch

- name: Check for staged changes
run: |
git diff --exit-code

# TODO build and test with npm
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ Documentation for the PxApi
When creating a PR for updatedating [PxAPI-2.yml](PxAPI-2.yml)
please use the following command to also include changes in generated server code.

ASP.NET Core 8.0 Server

```sh
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v7.11.0 generate -i /local/PxAPI-2.yml -g aspnetcore -c /local/aspnetcore-generator-config.yml -o /local
```

TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/)

```sh
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v7.11.0 generate -i /local/PxAPI-2.yml -g typescript-fetch -c /local/typescript-fetch-generator-config.yml -o /local/typescript-fetch
```

Replace `${PWD}` with `$(pwd)` when running on Linux

## PxWeb.Api2.Server - ASP.NET Core 8.0 Server
Expand Down
6 changes: 6 additions & 0 deletions typescript-fetch-generator-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
additionalProperties:
licenseName: Apache-2.0
npmName: pxwebapi-client
#npmRepository:
npmVersion: 0.0.1
snapshot: false
4 changes: 4 additions & 0 deletions typescript-fetch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
1 change: 1 addition & 0 deletions typescript-fetch/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
24 changes: 24 additions & 0 deletions typescript-fetch/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
package.json
60 changes: 60 additions & 0 deletions typescript-fetch/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.gitignore
.npmignore
README.md
src/apis/ConfigurationApi.ts
src/apis/NavigationApi.ts
src/apis/SavedQueriesApi.ts
src/apis/TableApi.ts
src/apis/index.ts
src/index.ts
src/models/Adjustment.ts
src/models/ApiFeature.ts
src/models/ClassType.ts
src/models/CodeListInformation.ts
src/models/CodeListMetadata.ts
src/models/CodeListResponse.ts
src/models/CodeListType.ts
src/models/CodeListsResponse.ts
src/models/ConfigResponse.ts
src/models/Contact.ts
src/models/Dataset.ts
src/models/DimensionExtension.ts
src/models/DimensionValue.ts
src/models/ExtensionDimension.ts
src/models/ExtensionRoot.ts
src/models/ExtensionRootPx.ts
src/models/FolderContentItem.ts
src/models/FolderContentItemTypeEnum.ts
src/models/FolderInformation.ts
src/models/FolderResponse.ts
src/models/Heading.ts
src/models/JsonstatCategory.ts
src/models/JsonstatCategoryUnitValue.ts
src/models/JsonstatExtensionLink.ts
src/models/JsonstatLink.ts
src/models/KeyValuePair.ts
src/models/Language.ts
src/models/Link.ts
src/models/MeasuringType.ts
src/models/Note.ts
src/models/OutputFormatParamType.ts
src/models/OutputFormatType.ts
src/models/PageInfo.ts
src/models/PathElement.ts
src/models/PriceType.ts
src/models/Problem.ts
src/models/Role.ts
src/models/SavedQuery.ts
src/models/SelectionResponse.ts
src/models/SourceReference.ts
src/models/Table.ts
src/models/TableResponse.ts
src/models/TablesResponse.ts
src/models/TimeUnit.ts
src/models/ValueMap.ts
src/models/VariablePlacementType.ts
src/models/VariableSelection.ts
src/models/VariablesSelection.ts
src/models/index.ts
src/runtime.ts
tsconfig.json
1 change: 1 addition & 0 deletions typescript-fetch/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.11.0
46 changes: 46 additions & 0 deletions typescript-fetch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## pxwebapi-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:

Environment
* Node.js
* Webpack
* Browserify

Language level
* ES5 - you must have a Promises/A+ library installed
* ES6

Module system
* CommonJS
* ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))

### Building

To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```

### Publishing

First build the package then run `npm publish`

### Consuming

navigate to the folder of your consuming project and run one of the following commands.

_published:_

```
npm install pxwebapi-client@0.0.1 --save
```

_unPublished (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
```
30 changes: 30 additions & 0 deletions typescript-fetch/package-lock.json

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

20 changes: 20 additions & 0 deletions typescript-fetch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "pxwebapi-client",
"version": "0.0.1",
"description": "OpenAPI client for PxWebApi 2.0",
"author": "OpenAPI-Generator",
"repository": {
"type": "git",
"url": "https://github.com/PxTools/PxApiSpecs.git"
},
"license": "Apache-2.0",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
"devDependencies": {
"typescript": "^4.0 || ^5.0"
}
}
59 changes: 59 additions & 0 deletions typescript-fetch/src/apis/ConfigurationApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* tslint:disable */
/* eslint-disable */
/**
* PxApi
* This api lets you do 2 things; Find a table(Navigation) and use a table (Table). _Table below is added to show how tables can be described in yml._ **Table contains status code this API may return** | Status code | Description | Reason | | ------- | ----------- | --------------------- | | 200 | Success | The endpoint has delivered response for the request | | 400 | Bad request | If the request is not valid | | 403 | Forbidden | number of cells exceed the API limit | | 404 | Not found | If the URL in request does not exist | | 429 | Too many request | Requests exceed the API time limit. Large queries should be run in sequence | | 50X | Internal Server Error | The service might be down |
*
* The version of the OpenAPI document: 2.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
ConfigResponse,
Problem,
} from '../models/index';
import {
ConfigResponseFromJSON,
ConfigResponseToJSON,
ProblemFromJSON,
ProblemToJSON,
} from '../models/index';

/**
*
*/
export class ConfigurationApi extends runtime.BaseAPI {

/**
* Get API configuration settings.
*/
async getApiConfigurationRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ConfigResponse>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/config`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ConfigResponseFromJSON(jsonValue));
}

/**
* Get API configuration settings.
*/
async getApiConfiguration(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ConfigResponse> {
const response = await this.getApiConfigurationRaw(initOverrides);
return await response.value();
}

}
Loading
Loading