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

Don't indent with tabs if mode is openapi #4315

Merged
merged 2 commits into from Dec 16, 2021

Conversation

develohpanda
Copy link
Contributor

@develohpanda develohpanda commented Dec 16, 2021

Closes #4313, further investigation notes in the parent PR. This PR preserves the existing behavior, where indentWithTabs was ignored in the design tab, regardless of if the spec was written in YAML or JSON.

Demo of the bug and fix: https://www.loom.com/share/483d0d02f9bf4d1d8657b9a7948c3d19

changelog(Fixes): Will no longer indent with tabs for YAML OpenAPI specs when the indentWithTabs setting is on

@vercel vercel bot temporarily deployed to Preview December 16, 2021 06:47 Inactive
@develohpanda develohpanda enabled auto-merge (squash) December 16, 2021 06:48
Copy link
Member

@filfreire filfreire left a comment

Choose a reason for hiding this comment

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

@develohpanda I tested out your branch locally, and it seems to have solved the issue.

Should we offer to "reformat" a doc that has been purposefully filled with tabs as some sort of improvement/help for beginner users?

Using this wrongful spec that has been edited to be with tabs

openapi: 3.0.0
info:
	title: Sample API
	description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
	version: 0.1.9
servers:
	- url: http://api.example.com/v1
		description: Optional server description, e.g. Main (production) server
	- url: http://staging-api.example.com
		description: Optional server description, e.g. Internal staging server for testing
paths:
	/users:
		get:
			summary: Returns a list of users.
			description: Optional extended description in CommonMark or HTML.
			responses:
				'200':    # status code
					description: A JSON array of user names
					content:
						application/json:
							schema:
								type: array
								items:
									type: string

Folks would still get "weird" errors:

Screenshot 2021-12-16 at 10 40 49

And maybe Insomnia could have a simple check "We notice you have tab characters in this openapi doc which could cause errors, would you like to edit these?"

@develohpanda develohpanda merged commit dc56a99 into Kong:develop Dec 16, 2021
@filfreire filfreire added T-healthy Change was tested and seems ok T-tested-by-author Change has been tested by Insomnia Team / Kong Test Engineers labels Dec 16, 2021
@develohpanda
Copy link
Contributor Author

That's a good idea @filfreire. Probably not necessary for this fix to go out, but a nice to have for sure. It would be nice to expose some plugin API to achieve that. This plugin API could also be used to create a useful "convert swagger 2 to open api 3" plugin.

Thoughts, @wdawson?

@develohpanda
Copy link
Contributor Author

Also, my mistake for setting this to auto merge, given I was seeking reviews from both Eng and QA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-healthy Change was tested and seems ok T-tested-by-author Change has been tested by Insomnia Team / Kong Test Engineers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insomnia uses tabs to indent YAML by default
2 participants