Skip to content
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

fix: OpenAPI generator config - protected keyword #436

Closed
petermetz opened this issue Dec 17, 2020 · 0 comments · Fixed by #437
Closed

fix: OpenAPI generator config - protected keyword #436

petermetz opened this issue Dec 17, 2020 · 0 comments · Fixed by #437
Assignees
Labels
bug Something isn't working
Milestone

Comments

@petermetz
Copy link
Contributor

petermetz commented Dec 17, 2020

Describe the bug

We are not compliant with the RFC 7515 spec when it comes to our generated models.

Currently our OpenAPI spec generation has an issue with the models defined for representing RFC 7515 JSON Web Signatures 1 with the field protected being mangled by the OpenAPI generator because protected is a soft reserved keyword in Typescript.
Since protected is only a softly reserved keyword, this means that you can still declare classes/interfaces with fields that are called protected which is what we need since the RFC mentioned above declares exactly that for JWS recipients.

To Reproduce

Build the project and observe that the generated code looks like this:

/**
 * A JSON Web Signature. See: https://tools.ietf.org/html/rfc7515 for info about standard.
 * @export
 * @interface JWSRecipient
 */
export interface JWSRecipient {
    /**
     * 
     * @type {string}
     * @memberof JWSRecipient
     */
    signature: string;
    /**
     * 
     * @type {string}
     * @memberof JWSRecipient
     */
    _protected?: string;
    /**
     * 
     * @type {{ [key: string]: object; }}
     * @memberof JWSRecipient
     */
    header?: { [key: string]: object; };
}

Expected behavior

The generated code should look like this:

/**
 * A JSON Web Signature. See: https://tools.ietf.org/html/rfc7515 for info about standard.
 * @export
 * @interface JWSRecipient
 */
export interface JWSRecipient {
    /**
     * 
     * @type {string}
     * @memberof JWSRecipient
     */
    signature: string;
    /**
     * 
     * @type {string}
     * @memberof JWSRecipient
     */
    protected?: string;
    /**
     * 
     * @type {{ [key: string]: object; }}
     * @memberof JWSRecipient
     */
    header?: { [key: string]: object; };
}

Cloud provider or hardware configuration:

Dev machine

Operating system name, version, build:

Linux 5.4.0-58-generic x86_64
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

v0.2.0

Hyperledger Cactus Plugins/Connectors Used

N/A

Additional context

OpenAPITools/openapi-generator#7100 (comment)

cc: @takeutak @sfuji822 @hartm @jonathan-m-hamilton

@petermetz petermetz added the bug Something isn't working label Dec 17, 2020
@petermetz petermetz added this to the v0.3.0 milestone Dec 17, 2020
@petermetz petermetz self-assigned this Dec 17, 2020
petermetz added a commit to petermetz/cacti that referenced this issue Dec 17, 2020
This changes makes it so that model properties named `protected` will
no longer get mangled by the OpenAPI generator into `_protected`.
This is needed so that our generated models can be compliant with the
JWS RFC [1]

Since `protected` is only a softly reserved keyword, this means that
you can still declare classes/interfaces with fields that are called
`protected` which is what we need since the RFC mentioned above
declares exactly that for JWS recipients.

[1]: https://tools.ietf.org/html/rfc7515

Fixes hyperledger-cacti#436

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit that referenced this issue Dec 18, 2020
This changes makes it so that model properties named `protected` will
no longer get mangled by the OpenAPI generator into `_protected`.
This is needed so that our generated models can be compliant with the
JWS RFC [1]

Since `protected` is only a softly reserved keyword, this means that
you can still declare classes/interfaces with fields that are called
`protected` which is what we need since the RFC mentioned above
declares exactly that for JWS recipients.

[1]: https://tools.ietf.org/html/rfc7515

Fixes #436

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
(cherry picked from commit 7eb58a7)
petermetz added a commit that referenced this issue Jan 5, 2021
This changes makes it so that model properties named `protected` will
no longer get mangled by the OpenAPI generator into `_protected`.
This is needed so that our generated models can be compliant with the
JWS RFC [1]

Since `protected` is only a softly reserved keyword, this means that
you can still declare classes/interfaces with fields that are called
`protected` which is what we need since the RFC mentioned above
declares exactly that for JWS recipients.

[1]: https://tools.ietf.org/html/rfc7515

Fixes #436

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant