Skip to content

feat: add support for refs to shorthand parameter syntax#250

Merged
erunion merged 1 commit intoreadmeio:mainfrom
Khauri:feat-shorthand-refs
Mar 17, 2022
Merged

feat: add support for refs to shorthand parameter syntax#250
erunion merged 1 commit intoreadmeio:mainfrom
Khauri:feat-shorthand-refs

Conversation

@Khauri
Copy link
Copy Markdown
Contributor

@Khauri Khauri commented Mar 7, 2022

🧰 What's being changed?

Adds support for using refs in the shorthand parameter syntax.
Pointers to local files and uri's are both supported via a simple heuristic.

Default argument isn't supported because that's a property of the referenced schema itself(?)
Currently no error will be thrown but the default will be ignored if provided.

Examples include:

# short-form, relative to document, ie #/components/ or #/definitions is inferred based on api version
(body) pet {ref:schemas/Pet} some description

# fully qualified relative to document
(body) pet {ref:#/components/schemas/Pet} some description

# local file (with JSON pointer)
(body) pet {ref:local.json#/components/schemas/Pet} some description

# external file (with JSON pointer)
(body) pet (ref:http://example.com/#/components/schemas/Pet} some description

(Resolves #212)

🧬 Testing

I added test cases in loader.test.js that demonstrate the expected output.

@erunion erunion self-assigned this Mar 7, 2022
@erunion erunion added the enhancement New feature or request label Mar 7, 2022
@erunion erunion self-requested a review March 7, 2022 17:26
Copy link
Copy Markdown
Member

@erunion erunion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

@erunion erunion changed the title Add refs to shorthand parameter syntax feat: add support for refs to shorthand parameter syntax Mar 17, 2022
@erunion erunion merged commit e5fef29 into readmeio:main Mar 17, 2022
@erunion
Copy link
Copy Markdown
Member

erunion commented Mar 17, 2022

Published to 5.2.0. Thanks! https://github.com/readmeio/swagger-inline/releases/tag/5.2.0

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameter shorthand schema instead of type

2 participants