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

Support Markup and I18N #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support Markup and I18N #76

wants to merge 1 commit into from

Conversation

maxlinc
Copy link

@maxlinc maxlinc commented Jul 29, 2014

This is an alternate proposal to simply defining the "description" field as being Markdown. I did this quickly via the GitHub editor, but if it looks good it could be cleaned up with:

  • Default values
  • Make a reusable definition for "documentation" in case we want to use it for summary or any other sections.

This PR allows:

A simple string description

# Note: We need to decide what the default is if only a string is given... plaintext? HTML? Markdown?
description: |
  The description can be a simple string
  with or without newlines.

Explicitly selecting a markup format

description:
  format: markdown # optional - need to choose a default 
  content: |
    The description could also have an explicit format and content section, so it can
    use things like [http://daringfireball.net/projects/markdown/](http://daringfireball.net/projects/markdown/)
    or perhaps other supported markup languages like [asciidoc](http://www.methods.co.nz/asciidoc/)

The use of translation keys

This could allow Swagger-UI to be hooked up to translation tools or services like Transifex.

description:
  format: markdown # optional - need to choose a default
  translation_key: description_for_some_api

This is an alternate proposal to simply defining the "description" field as being Markdown. I did this quickly via the GitHub editor, but if it looks good it could be cleaned up with:
- Default values
- Make a reusable definition for "documentation" in case we want to use it for `summary` or any other sections.

This PR allows:

### A simple string description

```yaml
# Note: We need to decide what the default is if only a string is given... plaintext? HTML? Markdown?
description: |
  The description can be a simple string
  with or without newlines.
```

### Explicitly selecting a markup format

```yaml
description:
  format: markdown # optional - need to choose a default 
  content: |
    The description could also have an explicit format and content section, so it can
    use things like [http://daringfireball.net/projects/markdown/](http://daringfireball.net/projects/markdown/)
    or perhaps other supported markup languages like [asciidoc](http://www.methods.co.nz/asciidoc/)
```

### The use of translation keys

This could allow Swagger-UI to be hooked up to translation tools or services like [Transifex](https://www.transifex.com/).

```yaml
description:
  format: markdown # optional - need to choose a default
  translation_key: desciption_for_some_api
```
@maxlinc
Copy link
Author

maxlinc commented Jul 29, 2014

I am worried this could be a bit tricky for implementors to parse. I know how I'd do it in Ruby but I'm not sure about other Swagger implementors.

@fehguy
Copy link

fehguy commented Jul 29, 2014

I don't think parsing will be the problem, but we do need to support JSON.

A literal translation of:

description: |
  The description can be a simple string
  with or without newlines.

is

{
  "description": "The description can be a simple string\nwith or without newlines.\n"
}

@maxlinc
Copy link
Author

maxlinc commented Jul 29, 2014

Those all support JSON as well. I wrote in YAML because it looks nicer and allows comments* :)

This should be much less likely to have any JSON vs YAML issues than the current Swagger-Editor behavior, because it is based on the presence or absence of the "format" parameter, rather than the presence or absence of newlines -- which may be confusing when converting between different JSON and YAML string formats.

Note: *some JSON parsers ignore comments and Douglas Crockford said this, but JSON does not officially allow comments.

@mohsen1
Copy link

mohsen1 commented Jul 30, 2014

I like this. There should be a way to set format globally too

@Bradamant3
Copy link

Docs girl here, and I like it too. But I'll add what someone put into the email thread -- only in the description field. Not summary, not title, not operationID, not any other string. This might be getting into the gray area between spec and implementation, but I'll come down on the side of the spec needing it.

@maxlinc
Copy link
Author

maxlinc commented Jul 30, 2014

@mohsen1 good point that format could be set globally. What if it was only set globally, rather than supporting a format on each description?

I expect that different organizations will want to use different markup languages, but I don't think as many organizations would want to mix AsciiDoc and Markdown (or whatever) in the same document.

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.

4 participants