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

apidom-reference: OpenAPI 3.1 normalization #2362

Closed
12 tasks done
Tracked by #2289
char0n opened this issue Dec 9, 2022 · 2 comments
Closed
12 tasks done
Tracked by #2289

apidom-reference: OpenAPI 3.1 normalization #2362

char0n opened this issue Dec 9, 2022 · 2 comments
Assignees
Labels

Comments

@char0n
Copy link
Member

char0n commented Dec 9, 2022

swagger-client has concept of normalization. This concept needs to be ported in ApiDOM as well. The goal of this issue is to research the process of normalization, understand it and implement it on ApiDOM side.

Research notes:

  • normalization in swagger-client is performed on already dereferenced definition.
  • can be skipped using skipNormalization option
  • current normalization is mostly built to support OpenAPI 2.0 (only partial support for 3.0.x)
  • decorates OpenAPI definition with $$normalized: boolean field and skips the normalization process if it detects that the field is truthy
  • add normalized operationIds for Operation Objects that does have them
  • correct Link.operationId references after the operationId normalization
  • when normalizing operationIds v2OperationIdCompatibilityMode needs to be supported
  • Parameter Objects are inherited from PathItem.parameters to Operation.parameters field. The rules of inheritance are defined here
  • Security Requirements Objects are inherited from OpenAPI.security to Operation.security field. The rules of inheritance are defined here and here
  • Server Objects are inherited in following sequence -> OpenAPI.servers -> PathItem.servers -> Operation.servers
  • Parameter.example|examples normalization
  • Header.example | examples normalization
@char0n char0n self-assigned this Dec 9, 2022
@char0n char0n added enhancement New feature or request OpenAPI 3.1 ApiDOM labels Dec 9, 2022
@char0n char0n changed the title OpenAPI 3.1 - normalization apidom-reference: OpenAPI 3.1 normalization Dec 9, 2022
@char0n
Copy link
Member Author

char0n commented Dec 15, 2022

In swagger-client integration we ideally want to use opId function from swagger-client. Function needs to be adapted in order to work. Here is a adaptation recipe:

const apiDOM = await parse(yamlDefinition);
const openApiElement = OpenApi3_1Element.refract(apiDOM.result, {
  plugins: [
    refractorPluginNormalizeOperationIds({
      operationIdNormalizer: (operationId, path, method) => {
        return opId({ operationId }, path, method, { v2OperationIdCompatibilityMode });
      },
    }),
  ],
});

char0n added a commit that referenced this issue Dec 16, 2022
Docs has been provided for following plugins:

- refractorPluginNormalizeParameters
- refractorPluginNormalizeSecurityRequirements
- refractorPluginNormalizeServers
- refractorPluginNormalizeOperationIds

Refs #2362
char0n added a commit that referenced this issue Dec 16, 2022
Docs has been provided for following plugins:

- refractorPluginNormalizeParameters
- refractorPluginNormalizeSecurityRequirements
- refractorPluginNormalizeServers
- refractorPluginNormalizeOperationIds

Refs #2362
char0n added a commit that referenced this issue Jan 1, 2023
New dispatcher was used in every namespace package.

Refs #2362
char0n added a commit that referenced this issue Jan 1, 2023
New dispatcher was used in every namespace package.

Refs #2362
char0n added a commit that referenced this issue Jan 3, 2023
Affected refractor plugins
- normalize-header-examples
- normalize-parameter-examples

Refs #2362
char0n added a commit that referenced this issue Jan 3, 2023
…2434)

Affected refractor plugins
- normalize-header-examples
- normalize-parameter-examples

Refs #2362
@char0n
Copy link
Member Author

char0n commented Jan 3, 2023

Closing this issue as it has been addressed by multiple PRs and number of normalization refractor plugins have been introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant