npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thing-description-playground/td_to_openapi

v1.3.1

Published

Provides openAPI instance generation for Thing Descriptions in the Web of Things - Thing Description Playground.

Downloads

28

Readme

@thing-description-playground/TD_TO_OPENAPI

The package providing support for OpenAPI instance generation (output as json or yaml), using a Thing Description as input.

Abbreviations

  • OAP: OpenAPI
  • TD: Thing Description

Limitations

  • Semantics
    • Some semantic annotations of the TD are converted to custom fields (prefixed by x-) in the openAPI output (e.g. @context -> x-@context) to provide a user who inspects the instance additional information.
    • Most semantic information is lost by converting a TD to an openAPI instance, since converting it is not possible or does not make any sense because no consumer of an openAPI isntance uses it.
  • Security
    • The openAPI specification does not support http authentification outside the header (query, body, cookie)
    • The TD specification does not support openIdConnect authentification
    • Information that is not required to describe an oauth flow in a TD is required for an openAPI instance (e.g. token url)
    • OAP supports alternative (only one has to be fullfilled) security objects, which can contain more than one security scheme (per object all security schemes have to be fullfilled). A TD also supports one security object with multiple schemes, but not alternative objects.
    • The psk (pre shared key) security scheme of a TD can not be represented by an openAPI instance.
  • Async Operations
    • Events of a TD, which are by nature asynchronous, can only be represented in OAP using the http-longpoll subprotocol.
    • For the future the support of asyncAPI instance generation is planned.

Comments

  • A TD hasn't necessarily to be valid in order to be converted to an openAPI instance. This converter will only throw an Error if the invalid part has a strong effect on the conversion result, but tries to ignore the most cases. This is by purpose, since there is the possibility to validate a TD using, e.g., the playground core package and the conversion of experimental TDs for example to create new TD features, should be supported.

Usage

You can use this package to integrate OpenAPI instance generation from a TD in your application.

  • Install this package via NPM (npm install @thing-description-playground/td_to_openapi) (or clone repo and install the package with npm install)

  • Node.js or Browser import:

    • Node.js: Require the package and use the functions
    const tdToOpenAPI = require("@thing-description-playground/td_to_openapi")
    • Browser: Import the tdToOpenAPI object as a global by adding a script tag to your html.
    <script src="./node_modules/@thing-description-playground/td_to_openapi/dist/web-bundle.min.js"></script>
  • Now you can convert a TD to an OpenAPI instance.

    tdToOpenAPI(td).then( OpenAPI => {
      console.log(JSON.stringify(OpenAPI.json, undefined, 2))
      console.log(OpenAPI.yaml)
    })

    You can find usage examples in the tests folder, or the web and cli packages.

License

Licensed under the MIT license, see License.