Skip to content

feat!: improve names for anonymous schemas and messages#223

Closed
jonaslagoni wants to merge 3 commits intoasyncapi:masterfrom
jonaslagoni:feature/meaningful_ids
Closed

feat!: improve names for anonymous schemas and messages#223
jonaslagoni wants to merge 3 commits intoasyncapi:masterfrom
jonaslagoni:feature/meaningful_ids

Conversation

@jonaslagoni
Copy link
Member

@jonaslagoni jonaslagoni commented Jan 7, 2021

WIP: will change as I go depending on the output it provide.

Description

This PR gives anonymous schemas and messages meaningful ids instead of <anonymous-message-x> as well as giving parameters and header root schemas meaningful uid's. We switch over to use a path naming approach so one knows where the anonymous schema or name is located in the document.

Rules of naming

These are the rules for the uid generation:

  • Anonymous messages are given the name <channel-name>Message according to what channel it belong to.
  • Anonymous parameter schemas are given the name <channel-name><parameter-name>Parameter
  • Anonymous message header schemas are given the name <message-name><header-name>Header
  • Anonymous message payload schemas are given the name <message-name>Payload

Regarding the naming of nested schemas here is the procedure, the name will cumulative based on how deep the nesting goes, here is the rules for cumulating the name:

  • The parent schema's id will the be starting point <parent-schema-name>
  • If the current schema is a property of an object the property name is added <property-name>
  • The type of the schema is then added i.e. if of type object Object is appended to the name

So the full name of the anonymous schema will be<parent-schema-name><property-name><schema-type>Schema

The special cases

  • Two root schemas are referenced between headers, parameters and message payloads
    • If a schema already have a uid it is never changed again, the order of which uid is used is the following: payload, header, parameter

What it introduces

  • It changes the behavior of the naming of anonymous schemas and messages
  • Fixed some functions had the wrong type for callback for JSdoc
  • Changes the naming of parameters and components

Related issue(s)
fixes #176

@jonaslagoni jonaslagoni changed the title feat: improve names for anonymous schemas and messages feat!: improve names for anonymous schemas and messages Jan 7, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jonaslagoni
Copy link
Member Author

I am gonna close this PR and introduce it gradually as much as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anonymous schemas should have meaningful ids

1 participant