Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Added annotations to reflect OpenAPI 2.0 properties #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file removed annotations/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions annotations/openapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Standard RAML annotations defined for OAS 2.0

> This directory contains a set of standard annotations that represent pieces of OpenAPI Specification (OAS) properties that are not directly supported by the RAML 1.0 specification.

## Tools

The following tools are already using these annotions.

* [oas-raml-converter](https://github.com/mulesoft/oas-raml-converter)
30 changes: 30 additions & 0 deletions annotations/openapi/oas-annotations.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#%RAML 1.0 Library

usage: |
This library contains a set of standard OpenAPI related annotations that are not supported in RAML.

types:
externalDocs:
properties:
description?: string
url: string

annotationTypes:
oas-summary: !include oas-summary.raml
oas-deprecated: !include oas-deprecated.raml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for me it is more logical to create generic deprecated annotation, which is not specific to oas.

oas-info: !include oas-info.raml
oas-tags: !include oas-tags.raml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags - also looks as a pretty generic thing.

oas-schema-title: !include oas-schema-title.raml
oas-schema-exclusiveMaximum: !include oas-schema-exclusiveMaximum.raml
oas-schema-exclusiveMinimum: !include oas-schema-exclusiveMinimum.raml
oas-schema-format: !include oas-schema-format.raml
oas-schema-readOnly: !include oas-schema-readOnly.raml
oas-externalDocs: externalDocs
oas-tags-definition: !include oas-tags-definition.raml
oas-original-definition-name: !include oas-original-schema-name.raml
oas-x-: !include oas-extension.raml
oas-responses: !include oas-responses.raml
oas-responses-default: !include oas-responses-default.raml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oas-responses-default this one also looks pretty generic.

oas-ref: !include oas-ref.raml
oas-parameter-allowEmptyValue: !include oas-parameter-allowEmptyValue.raml
oas-parameter-collectionFormat: !include oas-parameter-collectionFormat.raml
10 changes: 10 additions & 0 deletions annotations/openapi/oas-deprecated.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `deprecated` property in the OpenAPI Specification that
you are allowed to define for any operation.

type: boolean
default: false
allowedTargets: Method

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we should constrain it to Methods only.

displayName: Deprecated (OAS)
8 changes: 8 additions & 0 deletions annotations/openapi/oas-extension.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `^x-` property which
is used to define extensions for the OpenAPI Specification.

type: any
displayName: Extensions (OAS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for me it does not looks like a good idea to convert all extensions into 1 annotation. (Imagine round trip from RAML to OAS and back, ideally we should convert raml annotations to extensions and then back to same annotations)

19 changes: 19 additions & 0 deletions annotations/openapi/oas-info.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `info` property in the OpenAPI Specification that you
are allowed to define at the root of an OpenAPI document.

allowedTargets: API
properties:
termsOfService?: string
contact?:
properties:
name?: string
url?: string
email?: string
license?:
properties:
name?: string
url?: string
displayName: Info (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-original-schema-name.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
OpenAPI 2.0 does support the usage of special characters for schema names that RAML
does not support for its type system. This annotation stores the original name.

type: string
allowedTargets: TypeDeclaration
displayName: Original Schema Name (OAS)
8 changes: 8 additions & 0 deletions annotations/openapi/oas-parameter-allowEmptyValue.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `allowEmptyValue` property in the OpenAPI Specification which
you are allowed to define inside a parameter definition.

type: boolean
displayName: Parameter AllowEmptyValue (OAS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should add allowedTargets: TypeDeclaration facet to this

10 changes: 10 additions & 0 deletions annotations/openapi/oas-parameter-collectionFormat.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#%RAML 1.0 AnnotationTypeDeclaration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we have a hidden problem with this annotation. (In RAML we have a strict definition of how arrays of the scalars should be serialised and it seems that it depends from position where we are referencing array type) :-(


usage: |
This annotation represents an equivalent to the `collectionFormat` property in the OpenAPI Specification which
you are allowed to define inside a parameter definition.

type: string
enum: [ csv, ssv, tsv, pipes, multi ]
default: csv
displayName: Parameter CollectionFormat (OAS)
10 changes: 10 additions & 0 deletions annotations/openapi/oas-ref.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `$ref` property in the OpenAPI Specification which
is used to reference to other elements defined in an OpenAPI document. This can be used where `$ref`
cannot be directly mapped to something in RAML. For example, you can reference to a response definition
under a status code property (e.g. "400").

type: string
displayName: References (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-responses-default.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `default` property in the OpenAPI Specification which
you are allowed to define as a possible response besides the HTTP status code.

type: any
allowedTargets: Method
displayName: Default Responses (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-responses.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `responses` property in the OpenAPI Specification which
you are allowed to define at the root of an OpenAPI document.

type: any
allowedTargets: API
displayName: Responses (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-schema-exclusiveMaximum.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `exclusiveMaximum` property in the OpenAPI Specification which
you are allowed to define inside a schema definition.

type: boolean
allowedTargets: TypeDeclaration
displayName: Schema ExclusiveMaximum (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-schema-exclusiveMinimum.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `exclusiveMinimum` property in the OpenAPI Specification which
you are allowed to define inside a schema definition.

type: boolean
allowedTargets: TypeDeclaration
displayName: Schema ExclusiveMinimum (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-schema-format.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `format` property in the OpenAPI Specification which
you are allowed to define inside a schema definition. It should only be used inside "string" types.

type: string
allowedTargets: TypeDeclaration
displayName: Schema Format (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-schema-readOnly.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `readOnly` property in the OpenAPI Specification which
you are allowed to define inside a schema definition.

type: boolean
allowedTargets: TypeDeclaration
displayName: Schema ReadOnly (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-schema-title.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `title` property in the OpenAPI Specification which
you are allowed to define for a particular definition.

type: string
allowedTargets: TypeDeclaration
displayName: Schema Title (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-summary.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `summary` property in the OpenAPI Specification which
you are allowed to define for any operation.

type: string
allowedTargets: Method
displayName: Summary (OAS)
16 changes: 16 additions & 0 deletions annotations/openapi/oas-tags-definition.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `tags` property in the OpenAPI Specification which
you are allowed to define at the root of an OpenAPI document.

uses:
lib: oas-annotations.raml

type: array
items:
properties:
name: string
description?: string
externalDocs?: lib.externalDocs
displayName: Tags Object (OAS)
9 changes: 9 additions & 0 deletions annotations/openapi/oas-tags.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#%RAML 1.0 AnnotationTypeDeclaration

usage: |
This annotation represents an equivalent to the `tag` property in the OpenAPI Specification which
you are allowed to define for any operation.

type: string[]
allowedTargets: Method

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it is only allowed to tag methods?

displayName: Tags (OAS)