jra-3.1-api

The ERIGrid 2.0 middleware API

https://github.com/erigrid2/jra-3.1-api

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.2%) to scientific vocabulary

Keywords

api middleware
Last synced: 6 months ago · JSON representation

Repository

The ERIGrid 2.0 middleware API

Basic Info
Statistics
  • Stars: 3
  • Watchers: 5
  • Forks: 1
  • Open Issues: 9
  • Releases: 0
Topics
api middleware
Created over 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

The ERIGrid 2.0 middleware API OpenAPI Definition

If you are using this code for research purposes, especially for your publication, please do not forget to cite one of these papers.

console @INPROCEEDINGS{10542755, author={Rajkumar, Vetrivel and Silano, Giuseppe and Gehrke, Oliver and Vogel, Steffen and Widl, Edmund and Paludetto, Gabriele and Rikos, Evangelos and Zerihun, Tesfaye Amare and Ştefanov, Alexandru and Palensky, Peter and Strasser, Thomas I.}, booktitle={2024 12th Workshop on Modeling and Simulation of Cyber-Physical Energy Systems (MSCPES)}, title={Laboratory Middleware for the Cyber-Physical Integration of Energy Research Infrastructures}, year={2024}, volume={}, number={}, pages={1-5}, doi={10.1109/MSCPES62135.2024.10542755}}

Working on your OpenAPI Definition

Install

  1. Install Node JS.
  2. Clone this repo and run npm install in the repo root.

Usage

npm start

Starts the reference docs preview server.

npm run build

Bundles the definition to the dist folder.

npm test

Validates the definition.

Contribution Guide

Below is a sample contribution guide. The tools in the repository don't restrict you to any specific structure. Adjust the contribution guide to match your own structure. However, if you don't have a structure in mind, this is a good place to start.

Update this contribution guide if you adjust the file/folder organization.

The .redocly.yaml controls settings for various tools including the lint tool and the reference docs engine. Open it to find examples and read the docs for more information.

Schemas

Adding Schemas

  1. Navigate to the openapi/components/schemas folder.
  2. Add a file named as you wish to name the schema.
  3. Define the schema.
  4. Refer to the schema using the $ref (see example below).
Example Schema

This is a very simple schema example: yaml type: string description: The resource ID. Defaults to UUID v4 maxLength: 50 example: 4f6cf35x-2c4y-483z-a0a9-158621f77a21 This is a more complex schema example: ``yaml type: object properties: id: description: The customer identifier string readOnly: true allOf: - $ref: ./ResourceId.yaml websiteId: description: The website's ID allOf: - $ref: ./ResourceId.yaml paymentToken: type: string writeOnly: true description: | A write-only payment token; if supplied, it will be converted into a payment instrument and be set as thedefaultPaymentInstrument. The value of this property will override thedefaultPaymentInstrument` in the case that both are supplied. The token may only be used once before it is expired. defaultPaymentInstrument: $ref: ./PaymentInstrument.yaml createdTime: description: The customer created time allOf: - $ref: ./ServerTimestamp.yaml updatedTime: description: The customer updated time allOf: - $ref: ./ServerTimestamp.yaml tags: description: A list of customer's tags readOnly: true type: array items: $ref: ./Tags/Tag.yaml revision: description: > The number of times the customer data has been modified.

  The revision is useful when analyzing webhook data to determine if the
  change takes precedence over the current representation.
type: integer
readOnly: true

_links: type: array description: The links related to resource readOnly: true minItems: 3 items: anyOf: - $ref: ./Links/SelfLink.yaml - $ref: ./Links/NotesLink.yaml - $ref: ./Links/DefaultPaymentInstrumentLink.yaml - $ref: ./Links/LeadSourceLink.yaml - $ref: ./Links/WebsiteLink.yaml _embedded: type: array description: >- Any embedded objects available that are requested by the expand querystring parameter. readOnly: true minItems: 1 items: anyOf: - $ref: ./Embeds/LeadSourceEmbed.yaml

```

Using the $ref

Notice in the complex example above the schema definition itself has $ref links to other schemas defined.

Here is a small excerpt with an example:

yaml defaultPaymentInstrument: $ref: ./PaymentInstrument.yaml

The value of the $ref is the path to the other schema definition.

You may use $refs to compose schema from other existing schema to avoid duplication.

You will use $refs to reference schema from your path definitions.

Editing Schemas

  1. Navigate to the openapi/components/schemas folder.
  2. Open the file you wish to edit.
  3. Edit.

Paths

Adding a Path

  1. Navigate to the openapi/paths folder.
  2. Add a new YAML file named like your URL endpoint except replacing / with @ and putting path parameters into curly braces like {example}.
  3. Add the path and a ref to it inside of your openapi.yaml file inside of the openapi folder.

Example addition to the openapi.yaml file: yaml '/customers/{id}': $ref: './paths/customers@{id}.yaml'

Here is an example of a YAML file named customers@{id}.yaml in the paths folder:

yaml get: tags: - Customers summary: Retrieve a list of customers operationId: GetCustomerCollection description: | You can have a markdown description here. parameters: - $ref: ../components/parameters/collectionLimit.yaml - $ref: ../components/parameters/collectionOffset.yaml - $ref: ../components/parameters/collectionFilter.yaml - $ref: ../components/parameters/collectionQuery.yaml - $ref: ../components/parameters/collectionExpand.yaml - $ref: ../components/parameters/collectionFields.yaml responses: '200': description: A list of Customers was retrieved successfully headers: Rate-Limit-Limit: $ref: ../components/headers/Rate-Limit-Limit.yaml Rate-Limit-Remaining: $ref: ../components/headers/Rate-Limit-Remaining.yaml Rate-Limit-Reset: $ref: ../components/headers/Rate-Limit-Reset.yaml Pagination-Total: $ref: ../components/headers/Pagination-Total.yaml Pagination-Limit: $ref: ../components/headers/Pagination-Limit.yaml Pagination-Offset: $ref: ../components/headers/Pagination-Offset.yaml content: application/json: schema: type: array items: $ref: ../components/schemas/Customer.yaml text/csv: schema: type: array items: $ref: ../components/schemas/Customer.yaml '401': $ref: ../components/responses/AccessForbidden.yaml x-code-samples: - lang: PHP source: $ref: ../code_samples/PHP/customers/get.php post: tags: - Customers summary: Create a customer (without an ID) operationId: PostCustomer description: Another markdown description here. requestBody: $ref: ../components/requestBodies/Customer.yaml responses: '201': $ref: ../components/responses/Customer.yaml '401': $ref: ../components/responses/AccessForbidden.yaml '409': $ref: ../components/responses/Conflict.yaml '422': $ref: ../components/responses/InvalidDataError.yaml x-code-samples: - lang: PHP source: $ref: ../code_samples/PHP/customers/post.php

You'll see extensive usage of $refs in this example to different types of components including schemas.

You'll also notice $refs to code samples.

Code samples

  1. Navigate to the openapi/code_samples folder.
  2. Navigate to the <language> (e.g. PHP) sub-folder.
  3. Navigate to the path folder, and add ref to the code sample.

You can add languages by adding new folders at the appropriate path level.

More details inside the code_samples folder README.

Funding acknowledgement

European Flag The development of JRA3.1 API has been supported by the ERIGrid 2.0 project of the H2020 Programme under Grant Agreement No. 870620

Owner

  • Name: ERIGrid 2.0
  • Login: ERIGrid2
  • Kind: organization
  • Location: Europe

European Research Infrastructure supporting Smart Grid and Smart Energy Systems Research, Technology Development, Validation and Roll Out – Second Edition

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Dependencies

package-lock.json npm
  • @redocly/ajv 8.6.4
  • @redocly/openapi-cli 1.0.0-beta.91
  • @redocly/openapi-core 1.0.0-beta.91
  • @types/glob 7.2.0
  • @types/minimatch 3.0.5
  • @types/node 14.18.12
  • ansi-regex 5.0.1
  • ansi-styles 4.3.0
  • anymatch 3.1.2
  • argparse 2.0.1
  • assert-node-version 1.0.3
  • async 2.6.3
  • balanced-match 1.0.2
  • binary-extensions 2.2.0
  • brace-expansion 1.1.11
  • braces 3.0.2
  • chokidar 3.5.3
  • cliui 7.0.4
  • color-convert 2.0.1
  • color-name 1.1.4
  • colorette 1.4.0
  • concat-map 0.0.1
  • debug 3.2.7
  • debug 4.3.4
  • emoji-regex 8.0.0
  • escalade 3.1.1
  • expected-node-version 1.0.2
  • fast-deep-equal 3.1.3
  • fill-range 7.0.1
  • fs.realpath 1.0.0
  • fsevents 2.3.2
  • get-caller-file 2.0.5
  • glob 7.2.0
  • glob-parent 5.1.2
  • glob-promise 3.4.0
  • handlebars 4.7.7
  • inflight 1.0.6
  • inherits 2.0.4
  • is-binary-path 2.1.0
  • is-extglob 2.1.1
  • is-fullwidth-code-point 3.0.0
  • is-glob 4.0.3
  • is-number 7.0.0
  • js-levenshtein 1.1.6
  • js-yaml 4.1.0
  • json-schema-traverse 1.0.0
  • lodash 4.17.21
  • lodash.isequal 4.5.0
  • minimatch 3.1.2
  • minimist 1.2.6
  • mkdirp 0.5.6
  • ms 2.1.2
  • ms 2.1.3
  • neo-async 2.6.2
  • node-fetch 2.6.7
  • normalize-path 3.0.0
  • once 1.4.0
  • path-is-absolute 1.0.1
  • picomatch 2.3.1
  • pluralize 8.0.0
  • portfinder 1.0.28
  • punycode 2.1.1
  • queue-microtask 1.2.3
  • randombytes 2.1.0
  • readable-stream 3.6.0
  • readdirp 3.6.0
  • require-directory 2.1.1
  • require-from-string 2.0.2
  • safe-buffer 5.2.1
  • semver 5.7.1
  • simple-websocket 9.1.0
  • source-map 0.6.1
  • string-width 4.2.3
  • string_decoder 1.3.0
  • strip-ansi 6.0.1
  • to-regex-range 5.0.1
  • tr46 0.0.3
  • uglify-js 3.15.3
  • uri-js 4.4.1
  • util-deprecate 1.0.2
  • webidl-conversions 3.0.1
  • whatwg-url 5.0.0
  • wordwrap 1.0.0
  • wrap-ansi 7.0.0
  • wrappy 1.0.2
  • ws 7.5.7
  • y18n 5.0.8
  • yaml-ast-parser 0.0.43
  • yargs 17.0.1
  • yargs-parser 20.2.9
package.json npm
  • @redocly/openapi-cli ^1.0.0-beta.91
.github/workflows/build-docs.yaml actions
  • actions/checkout v2 composite
  • peaceiris/actions-gh-pages v3 composite