An open API service indexing awesome lists of open source software.

https://github.com/teamdigitale/dati-semantic-schema-editor

Semantic Schema Editor
https://github.com/teamdigitale/dati-semantic-schema-editor

api ontology semantics

Last synced: 25 days ago
JSON representation

Semantic Schema Editor

Awesome Lists containing this project

README

          

# Schema Editor

Italia OpenAPI Schema Editor is developed on [Swagger Editor](https://github.com/swagger-api/swagger-editor).

This repository uses [PNPM](https://pnpm.io) and [turborepo](https://turbo.build/) for packages management, and [changesets](https://github.com/changesets/changesets) for versioning and publishing.

![Build Status](https://github.com/teamdigitale/dati-semantic-schema-editor/actions/workflows/pages.yml/badge.svg)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Table of contents

- 💻 [Usage](#usage)
- 🚀 [API](#api)
- 📋 [Development](#development)
- 📝 [Contributing](#contributing)
- ⚖️ [License](#license)

## Usage

### Usage with Public Docker Image

To launch the application using the public docker image, run the following command:

```bash
docker run -d -p 8000:8000 ghcr.io/teamdigitale/dati-semantic-schema-editor:latest
```

or pick a specific version from the [github container registry](https://github.com/teamdigitale/dati-semantic-schema-editor/pkgs/container/dati-semantic-schema-editor).

### Usage with Docker

To launch the application, just run docker compose

- that will build and deploy the app - and
open the browser

```bash
docker compose up -d app
open http://localhost:5000
```

### Local Usage

To use the Semantic Schema Editor all you need to do is installing the `@teamdigitale/schema-editor` plugin
and use the component in your application.

```typescript
import 'bootstrap-italia/dist/css/bootstrap-italia.min.css';
import '@fontsource/lora';
import '@fontsource/roboto-mono';
import '@fontsource/titillium-web';

import './App.scss';

import { SchemaEditor } from '@teamdigitale/schema-editor';
import '@teamdigitale/schema-editor/dist/style.css';

function App() {
const urlParams = new URLSearchParams(window.location.search);
const schemaUrl = urlParams.get('url');

return (
<>




>
);
}

export default App;

```

This repository contains various usage examples:

- [apps/example/src/App.tsx](./apps/example/src/App.tsx) - Showcase webapp;
- [apps/example/src/components/standalone](./apps/example/src/components/standalone) - Standalone editor;
- [apps/example/src/components/swaggerui-plugins-collection](./apps/example/src/components/swaggerui-plugins-collection) - Use the SwaggerUI component only.

## API

The project includes a REST API based on NestJS for calculating the semantic score of OpenAPI documents.

### Features

- **Semantic Score Calculation**: Endpoint to calculate the semantic score of OpenAPI 3.0 files (YAML/JSON)
- **Rate Limiting**: Protection against abuse through request throttling
- **Validation**: Automatic validation of OpenAPI documents
- **Documentation**: Swagger UI available in development mode

For detailed information about the API, see [apps/api/README.md](./apps/api/README.md).

## Development

### Develop with docker

To start the development environment with docker, run the following command:

```bash
docker compose up -d dev
```

This will run a development environment based on the [dev.dockerfile](./dev.dockerfile) and will start the development server.

### Installation

Ensure to have installed [PNPM](https://pnpm.io/installation) package manager.

Install node modules by running

```bash
pnpm install
```

### Running

Then simply execute

```bash
pnpm dev
```

to start all packages in development mode.

### Versioning and publishing

When developing a new feature or performing a new bugfix the version of the package(s) must be increased.
In order to process this correctly perform the following steps:

- Run `pnpm changeset` in the root of app in order to create a markdown containing the changes.

- Commit the generated files that are inside `.changeset` folder

- When the changesets files reach the "baseBranch" (actually "main"), **a github action will generate a new PR with updated packages versions**. Review the PR and **approve merge when ready to release a new version**.

- Once the PR is merged into the baseBranch, a github action will publish packages automatically, using trusted publish NPM capability.

- If you want to build and publish a pre-release version before going to the main branch, then rebase the "next" branch to the needed commit from main branch.
The github action will open a new PR with the "-next.X" tag. Once merged in the "next" branch it will publish the package(s) as described above.
For more informations and an example have a look at:
- https://changesets-docs.vercel.app/en/prereleases
- https://github.com/changesets/action/issues/69#issuecomment-774909280
- https://github.com/statelyai/xstate/pull/902

**Pay attention: never merge "next" branch into "main"!**

## Docker builds

To create images for the two webapps, run the following commands:

```bash
# Editor webapp
docker build . --target webapp --tag webapp:latest

# Showcase webapp
docker build . --target example --tag example:latest
```

After creating the desired image, run it with the following command, paying attention to change the listening ports and config file if needed:

```bash
docker run -p 80:80 --mount type=bind,source=${PWD}/my-custom-config.js,target=/usr/share/nginx/html/config.js webapp:latest
```

## Contributing

Please, see [CONTRIBUTING.md](CONTRIBUTING.md) for more details on:

- using [pre-commit](CONTRIBUTING.md#pre-commit);
- following the git flow and making good [pull requests](CONTRIBUTING.md#making-a-pr).

## License

Apache License 2.0 © [LICENSE](LICENSE)