Skip to content
Merged
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# OpenAPI Workflow Parser
# OpenAPI Workflow (Arazzo) Parser

[![](https://badgen.net/github/license/API-Flows/openapi-workflow-parser)](LICENSE)
[![](https://badgen.net/maven/v/maven-central/com.api-flows/openapi-workflow-parser)](https://repo1.maven.org/maven2/com/api-flows/openapi-workflow-parser/)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=API-Flows_openapi-workflow-parser&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=API-Flows_openapi-workflow-parser)

Parsing OpenAPI workflows.
Parsing API workflows.

## Overview

The OpenAPI Workflow parser is an open-source Java library designed to parse the [OpenAPI SIG-Workflows specification](https://github.com/OAI/sig-workflows) files. It reads an OpenAPI workflow file (JSON or YAML formats are supported) and creates the corresponding Java objects.
The OpenAPI Workflow parser is an open-source Java library designed to parse the [OAI Arazzo specification](https://https://github.com/OAI/Arazzo-Specification/) files. It reads an Arazzo file (JSON or YAML formats are supported) and creates the corresponding Java objects.

The parser's goal is to simplify the extraction and manipulation of OpenAPI workflows, helping developers create applications and tools that harness the semantic structure of API flows.
The parser's goal is to simplify the extraction and manipulation of workflows, helping developers create applications and tools that harness the semantic structure of API flows.

## Features

- **Workflow Parsing:** Reads OpenAPI specification files loading the corresponding Java objects.
- **Ease of Use:** Provides a simple way for developers to parse OpenAPI workflows.
- **Compatibility:** Supports OpenAPI specifications in JSON and YAML formats.
- **Validation:** Validates the OpenAPI specification according to the [Workflows Specification v1.0.0](https://github.com/OAI/sig-workflows/blob/main/versions/1.0.0.md).
- **Workflow Parsing:** Reads OAI Arazzo specification files loading the corresponding Java objects.
- **Ease of Use:** Provides a simple way for developers to parse workflows.
- **Compatibility:** Supports both JSON and YAML formats.
- **Validation:** Validates the specification according to the [Arazzo Specification v1.0.0](https://https://github.com/OAI/Arazzo-Specification/).

## Usage

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/apiflows/model/OpenAPIWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

public class OpenAPIWorkflow {

private String workflowsSpec;
private String arazzo;
private Info info;
private List<SourceDescription> sourceDescriptions = new ArrayList<>();
private List<Workflow> workflows = new ArrayList<>();
private Components components;

public String getWorkflowsSpec() {
return workflowsSpec;
public String getArazzo() {
return arazzo;
}

public void setWorkflowsSpec(String workflowsSpec) {
this.workflowsSpec = workflowsSpec;
public void setArazzo(String arazzo) {
this.arazzo = arazzo;
}

public Info getInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public OpenAPIWorkflowValidatorResult validate() {

OpenAPIWorkflowValidatorResult result = new OpenAPIWorkflowValidatorResult();

if (openAPIWorkflow.getWorkflowsSpec() == null || openAPIWorkflow.getWorkflowsSpec().isEmpty()) {
if (openAPIWorkflow.getArazzo() == null || openAPIWorkflow.getArazzo().isEmpty()) {
result.addError("'workflowsSpec' is undefined");
}

Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/apiflows/parser/OpenAPIWorkflowParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class OpenAPIWorkflowParserTest {

@Test
void parseFromFile() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = parser.parse(WORKFLOWS_SPEC_FILE);
assertNotNull(result.getOpenAPIWorkflow());
assertEquals("1.0.0-prerelease", result.getOpenAPIWorkflow().getWorkflowsSpec());
assertEquals("1.0.0", result.getOpenAPIWorkflow().getArazzo());
assertNotNull(result.getOpenAPIWorkflow().getInfo());
assertEquals("Petstore - Apply Coupons", result.getOpenAPIWorkflow().getInfo().getTitle());
assertNotNull(result.getOpenAPIWorkflow().getComponents());
Expand All @@ -30,11 +30,11 @@ void parseFromFile() {

@Test
void parseFromUrl() {
final String WORKFLOWS_SPEC_FILE = "https://raw.githubusercontent.com/API-Flows/openapi-workflow-parser/main/src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "https://raw.githubusercontent.com/API-Flows/openapi-workflow-parser/main/src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = parser.parse(WORKFLOWS_SPEC_FILE);
assertNotNull(result.getOpenAPIWorkflow());
assertEquals("1.0.0-prerelease", result.getOpenAPIWorkflow().getWorkflowsSpec());
assertEquals("1.0.0-prerelease", result.getOpenAPIWorkflow().getArazzo());
assertNotNull(result.getOpenAPIWorkflow().getInfo());
assertEquals("Petstore - Apply Coupons", result.getOpenAPIWorkflow().getInfo().getTitle());
}
Expand Down Expand Up @@ -71,12 +71,12 @@ void parseFromJsonFile() {
OpenAPIWorkflowParserResult result = parser.parse(WORKFLOWS_SPEC_FILE);
assertTrue(result.isJson());
assertNotNull(result.getOpenAPIWorkflow());
assertEquals("1.0.0", result.getOpenAPIWorkflow().getWorkflowsSpec());
assertEquals("1.0.0", result.getOpenAPIWorkflow().getArazzo());
}

@Test
public void isYaml() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = parser.parse(WORKFLOWS_SPEC_FILE);
assertTrue(result.isYaml());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void getOperationsFromUrl() {

@Test
void bind() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = new OpenAPIWorkflowParser().parse(WORKFLOWS_SPEC_FILE);

Expand All @@ -58,7 +58,7 @@ void bind() {

@Test
void bindFromUrl() {
final String WORKFLOWS_SPEC_FILE = "https://raw.githubusercontent.com/OAI/sig-workflows/main/examples/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "https://raw.githubusercontent.com/API-Flows/openapi-workflow-parser/main/src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = new OpenAPIWorkflowParser().parse(WORKFLOWS_SPEC_FILE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WorkflowBinderTest {

@Test
void bind() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";

OpenAPIWorkflowParserResult result = new OpenAPIWorkflowParser().parse(WORKFLOWS_SPEC_FILE);

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/apiflows/parser/util/HttpUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class HttpUtilTest {

@Test
void call() {
final String WORKFLOWS_SPEC_URL = "https://github.com/OAI/sig-workflows/blob/main/examples/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_URL = "https://raw.githubusercontent.com/API-Flows/openapi-workflow-parser/main/src/test/resources/1.0.0/pet-coupons.arazzo.yaml";
assertNotNull(httpUtil.call(WORKFLOWS_SPEC_URL));
}

@Test
void isUrl() {
final String WORKFLOWS_SPEC_URL = "https://github.com/OAI/sig-workflows/blob/main/examples/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_URL = "https://raw.githubusercontent.com/API-Flows/openapi-workflow-parser/main/src/test/resources/1.0.0/pet-coupons.arazzo.yaml";
assertTrue(httpUtil.isUrl(WORKFLOWS_SPEC_URL));
}
}
4 changes: 2 additions & 2 deletions src/test/java/com/apiflows/parser/util/PathUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class PathUtilTest {

@Test
void getFromFile() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";
assertFalse(pathUtil.getFromFile(WORKFLOWS_SPEC_FILE).isEmpty());
}

@Test
void isFile() {
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.workflow.yaml";
final String WORKFLOWS_SPEC_FILE = "src/test/resources/1.0.0/pet-coupons.arazzo.yaml";
assertTrue(pathUtil.isFile(WORKFLOWS_SPEC_FILE));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
workflowsSpec: 1.0.0-prerelease
arazzo: 1.0.0
info:
title: Petstore - Apply Coupons
version: 1.0.0
Expand Down Expand Up @@ -70,9 +70,9 @@ workflows:
- name: status
in: query
value: "available"
- name: $components.parameters.page
- reference: $components.parameters.page
value: 1
- name: $components.parameters.pageSize
- reference: $components.parameters.pageSize
value: 10
successCriteria:
- condition: $statusCode == 200
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/1.0.0/simple.workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
workflowsSpec: 1.0.0
arazzo: 1.0.0
info:
title: simple
version: v1
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/1.0.0/workflow.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"workflowsSpec": "1.0.0",
"arazzo": "1.0.0",
"info": {
"title": "simple",
"version": "v1",
Expand Down