Skip to content
This repository has been archived by the owner on Jul 2, 2019. It is now read-only.

Parse info.version #182

Closed
abacaphiliac opened this issue May 24, 2018 · 7 comments
Closed

Parse info.version #182

abacaphiliac opened this issue May 24, 2018 · 7 comments

Comments

@abacaphiliac
Copy link
Contributor

abacaphiliac commented May 24, 2018

Hi Team,

I need info.version to be available in my parse result. It looks like only title and description are parsed. I've looked into adding it as meta, like title. Nearly all of the swagger-zoo fixture tests fail due to the fixtures specifying a version which is apparently supposed to be ignored.

Is version truly supposed to be stripped, as swagger-zoo seems to indicate? Can version be removed from the fixtures (yaml and json) so that this project can parse it additively? Should I open an issue/request to swagger-zoo to add the parsed version to the fixtures? If so, is it an attribute, meta, or content?

Thanks for the consideration : )

@abacaphiliac
Copy link
Contributor Author

I made a mistake in my original description, suggesting that version could be removed from the fixtures. Version is required by Swagger, so that is not a viable option.

@kylef
Copy link
Member

kylef commented May 25, 2018

I think it probably makes sense that we could contain some kind of source document/version information into the parse result itself. We don't have a specific place for that in API Elements (the parse result format) so will have to give this some though as to where to place it.

One note, I don't believe this adapter supports more than one version, only Swagger 2.0 so you can assume the version would be 2.0 for now.

@abacaphiliac
Copy link
Contributor Author

To be clear, i'm looking for the info.version of my API, not the swagger version.

Thank you for the effort. Parse result is an interesting idea. I hadn't considered it : )

@abacaphiliac
Copy link
Contributor Author

For example, in a wrapper I've created to work around this issue I am using the following snippet to add info.version as a sibling to title in the API meta:

        if (this['swagger'].info && this['swagger'].info.version) {
            this['api'].meta.set('version', this['swagger'].info.version);
        }

I'm sure this can be enhanced, and does not handle source map, but it does make the required information available. My attempt at something similar in this project's source broke many swagger-zoo tests because the fixtures do not expect info.version to be parsed.

@kylef
Copy link
Member

kylef commented May 25, 2018

Oh sorry, I mis-understood, you are right. I did create apiaryio/api-elements#37 to track the other problem I mentioned.

I have the a similar comment though, we will have to decide where to place this in API Elements and then update the parser(s).

In your case, the meta section of an element is reserved and shouldn't be extended on per-element basis (see https://api-elements.readthedocs.io/en/latest/element-definitions.html). The idea of meta is that the semantics behind those apply to all element types in the tree. This type of information would belong in the attributes. I think perhaps version as string under attributes would make sense.

Members of meta SHOULD NOT be Element type specific; an exception to this MAY be the classes property. Members of attributes MAY be Element type specific.

This information should likely go into the attributes of the API Element.

@abacaphiliac
Copy link
Contributor Author

Would you like me to make the change in a request so that we can talk about the breaks (if any)? I'm happy to give it a shot.

@kylef
Copy link
Member

kylef commented Dec 7, 2018

This made it into the adapter a few releases ago (https://github.com/apiaryio/fury-adapter-swagger/releases/tag/v0.20.0), forgot to update this issue.

@kylef kylef closed this as completed Dec 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants