Customize Path Parameters

When it comes to getting path arguments right, Akita's automatic inference algorithms can usually get you most of the way there. Akita's path hints make it possible to customize path parameter inference.

32223222

You may customize paths in the "Customize Paths" tab of the API Model viewer.

What You Can Do with Hints

Collapse paths

If Akita is showing you /post/post-id-1 and /post/post-id-2 you can add an annotation /post/{postID} to collapse those paths.

Name path arguments for better readability

You can use path hints to name arguments. For example, if Akita parses your API as /post/{arg} you can add an annotation /post/{postID} and {arg} will be replaced by {postID} in the Akita Console.

Split paths

Say Akita is showing you /post/{arg} and you want it to not collapse some routes. You can add an annotation like /post/new to make sure it is always separated from /post/{arg}.

You can also use a “^” in /post/^to require that the segment not be a path parameter. For example, /post/^ will match /post/edit and /post/share. It ensures they do not get collapsed as /post/{arg}.

How Path Hints Get Applied

The Akita traffic inference engine uses your rules to help with path parameter inference:

  • The engine applies path hints in order of priority. Place your more specific path hints at the top.
  • A URL matches on the first path hint that applies—and at most one path hint. For example, if you have a hint /post/{postID} and then later /post/{postID}/project/{projectID}, the /post/{postID}/project/{projectID} hint will never get used. Switch the order to make sure both get used.
  • Hints are ‘prefix match’ and so your hint /post/{postID} will match a longer path like /post/post-id-1/edit and collapse it into /post/{postID}/edit.
  • Path hints apply to all future traffic analysis.

Path parameters only apply for specific hosts, so make sure to put the host(s) where you would like them to apply.

Examples

31063106

Annotation

Matches

Displayed as

/post/{postID}

/post/post-id-1
/post/post-id-2/edit
/post/post-id-3/project/project-id

/post/{postID}
/post/{postID}/edit
/post/{postID}/project/project-id

/post/{postID}/projects/{projectID}

/post/post-id-1/project/project-id

/post/{postID}/project/{projectID}

/post/{postID}/^

/post/post-id-1/share
/post/post-id-2/edit

/post/{postID}/share
/post/{postID}/edit


Did this page help you?