-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make protocol and auth traits #273
Changes from 18 commits
a5e7f52
ed94e5d
502454d
c7f3a32
b95b966
9f50617
a7d6165
f33ce9d
7318439
92b470c
b8290c4
175ef6d
06138f6
943ed09
248a9a4
2afe42a
cfcbdf4
0cdc69a
4410be0
2bcad8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -437,54 +437,6 @@ orphaned shapes. | |
This transformer does not remove shapes from the prelude. | ||
|
||
|
||
.. _includeAuth-transform: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are no longer needed since they're just normal traits. You can include/exclude traits using includeTraits, excludeTraits, etc |
||
|
||
includeAuth | ||
----------- | ||
|
||
Removes authentication schemes from shapes that do not match one of the | ||
given arguments (a list of authentication schemes). | ||
|
||
.. tabs:: | ||
|
||
.. code-tab:: json | ||
|
||
{ | ||
"version": "1.0", | ||
"projections": { | ||
"exampleProjection": { | ||
"transforms": [ | ||
{"name": "includeAuth", "args": ["aws.v4", "http-basic"]} | ||
] | ||
} | ||
} | ||
} | ||
|
||
|
||
.. _includeProtocols-transform: | ||
|
||
includeProtocols | ||
---------------- | ||
|
||
Removes protocols from service shapes that do not match one of the given | ||
arguments (a list of protocol names). | ||
|
||
.. tabs:: | ||
|
||
.. code-tab:: json | ||
|
||
{ | ||
"version": "1.0", | ||
"projections": { | ||
"exampleProjection": { | ||
"transforms": [ | ||
{"name": "includeProtocols", "args": ["aws.rest-json"]} | ||
] | ||
} | ||
} | ||
} | ||
|
||
|
||
.. _includeTags-transform: | ||
|
||
includeTags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ The Smithy Gradle plugin relies on a ``smithy-build.json`` file found at the | |
root of a project to define the actual process of building the OpenAPI | ||
specification. The following example defines a ``smithy-build.json`` file | ||
that builds an OpenAPI specification from a service for the | ||
``smithy.example#Weather`` service using the ``aws.rest-json-1.1`` protocol: | ||
``smithy.example#Weather`` service using the ``aws.protocols#restJson1`` protocol: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided to use |
||
|
||
.. code-block:: json | ||
:caption: smithy-build.json | ||
|
@@ -125,7 +125,7 @@ that builds an OpenAPI specification from a service for the | |
"plugins": { | ||
"openapi": { | ||
"service": "smithy.example#Weather", | ||
"protocol": "aws.rest-json-1.1" | ||
"protocol": "aws.protocols#restJson1" | ||
} | ||
} | ||
} | ||
|
@@ -155,14 +155,18 @@ service (string) | |
**Required**. The Smithy service :ref:`shape ID <shape-id>` to convert. | ||
|
||
protocol (string) | ||
The protocol name to use when converting Smithy to OpenAPI (for example, | ||
``aws.rest-json-1.1``. | ||
The protocol shape ID to use when converting Smithy to OpenAPI (for | ||
example, ``aws.protocols#restJson1``). | ||
|
||
Smithy will try to match the provided protocol name with an implementation | ||
of ``software.amazon.smithy.openapi.fromsmithy.OpenApiProtocol`` | ||
registered with a service provider implementation of | ||
``software.amazon.smithy.openapi.fromsmithy.CoreExtension``. | ||
|
||
.. important:: | ||
|
||
This property is required if a service supports multiple protocols. | ||
|
||
openapi.tags (boolean) | ||
Whether or not to include Smithy :ref:`tags <tags-trait>` in the result. | ||
|
||
|
@@ -197,8 +201,8 @@ openapi.keepUnusedComponents (boolean) | |
created specification. | ||
|
||
openapi.aws.jsonContentType (string) | ||
Sets the media-type to associate with the JSON payload of ``aws.json-*`` | ||
and ``aws.rest-json-*`` protocols | ||
Sets a custom media-type to associate with the JSON payload of | ||
JSON-based protocols. | ||
|
||
openapi.forbidGreedyLabels (boolean) | ||
Set to true to forbid greedy URI labels. By default, greedy labels will | ||
|
@@ -485,9 +489,6 @@ Other traits that influence API Gateway | |
``aws.api#service`` | ||
TODO | ||
|
||
``protocols`` | ||
TODO | ||
|
||
``aws.apigateway#apiKeySource`` | ||
Specifies the source of the caller identifier that will be used to | ||
throttle API methods that require a key. This trait is converted into | ||
|
@@ -532,7 +533,7 @@ Next, you need to create and configure an ``OpenApiConverter``: | |
OpenApiConverter converter = OpenApiConverter.create(); | ||
|
||
// Add any necessary settings... | ||
converter.putSetting(OpenApiConstants.PROTOCOL, "aws.rest-json-1.1"); | ||
converter.putSetting(OpenApiConstants.PROTOCOL, "aws.protocols#restJson1"); | ||
|
||
// Create a shape ID that points to the service. | ||
ShapeId serviceShapeId = ShapeId.from("smithy.example#Weather"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
.. _aws-authentication: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like protocols, I broke authentication traits into their own doc. Unlike protocols, I didn't give each trait it's own page. We could consider doing that if we perhaps add more extensive sigv4 documentation (for example, we may want to recreate the sigv4 test suite to be Smithy protocol tests). |
||
|
||
========================= | ||
AWS Authentication Traits | ||
========================= | ||
|
||
This document defines AWS authentication schemes. | ||
|
||
.. contents:: Table of contents | ||
:depth: 2 | ||
:local: | ||
:backlinks: none | ||
|
||
|
||
.. _aws.auth#sigv4-trait: | ||
|
||
``aws.auth#sigv4`` trait | ||
======================== | ||
|
||
Trait summary | ||
The ``aws.auth#sigv4`` trait adds support for `AWS signature version 4`_ | ||
to a service. | ||
Trait selector | ||
``service`` | ||
Trait value | ||
An ``object`` that supports the following properties: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 10 20 70 | ||
|
||
* - Property | ||
- Type | ||
- Description | ||
* - name | ||
- ``string`` | ||
- **Required**. The signature version 4 service signing name to use | ||
in the `credential scope`_ when signing requests. This value | ||
SHOULD match the ``arnNamespace`` property of the | ||
:ref:`aws.api#service-trait`. | ||
|
||
.. tabs:: | ||
|
||
.. code-tab:: smithy | ||
|
||
namespace aws.fooBaz | ||
|
||
use aws.api#service | ||
use aws.auth#sigv4 | ||
use aws.protocols#restJson1 | ||
|
||
@service(sdkId: "Some Value") | ||
@sigv4(name: "foobaz") | ||
@restJson1 | ||
service FooBaz { | ||
version: "2018-03-17", | ||
} | ||
|
||
.. code-tab:: json | ||
|
||
{ | ||
"smithy": "0.5.0", | ||
"shapes": { | ||
"aws.fooBaz#FooBaz": { | ||
"type": "service", | ||
"version": "2018-03-17", | ||
"traits": { | ||
"aws.protocols#restJson1": true, | ||
"aws.api#service": { | ||
"sdkId": "Some Value" | ||
}, | ||
"aws.auth#sigv4": { | ||
"name": "foobaz" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
.. _aws.auth#cognitoUserPools-trait: | ||
|
||
aws.auth#cognitoUserPools | ||
========================= | ||
|
||
Trait summary | ||
The ``aws.auth#cognitoUserPools`` trait adds support for | ||
`Amazon Cognito User Pools`_ to a service. | ||
Trait selector | ||
``service`` | ||
Trait value | ||
An ``object`` that supports the following properties: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 10 20 70 | ||
|
||
* - Property | ||
- Type | ||
- Description | ||
* - providerArns | ||
- ``[string]`` | ||
- **Required**. A list of the Amazon Cognito user pool ARNs. Each | ||
element is of this format: ``arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}``. | ||
|
||
.. code-block:: smithy | ||
|
||
namespace aws.fooBaz | ||
|
||
use aws.api#service | ||
use aws.auth#cognitoUserPools | ||
use aws.protocols#restJson1 | ||
|
||
@service(sdkId: "Some Value") | ||
@cognitoUserPools( | ||
providerArns: ["arn:aws:cognito-idp:us-east-1:123:userpool/123"]) | ||
@restJson1 | ||
service FooBaz { | ||
version: "2018-03-17", | ||
} | ||
|
||
|
||
.. _AWS signature version 4: https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html | ||
.. _credential scope: https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html | ||
.. _Amazon Cognito User Pools: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are flagged as not meeting Java conventions, but we need to carry the version numbers in the generated class.