Swagger-php: Is there a way to write annotations for 2 Swagger APIs in the same php repository ?

Created on 24 Dec 2017  路  5Comments  路  Source: zircote/swagger-php

Most helpful comment

I think this is still valid question because this project works by scanning files/folders annotations. Your solution would work if these API's would have completely different definitions and endpoints but what if i want to share the same model definition in both API's? I cant write 2 annotations so each API would read one of them? I'm currently wondering as well how to fix this.

All 5 comments

This question is not really related to this project.
You can generate multiple json by pointing to different paths to scan with this library, then once you have multiple json files, you can use latest swagger-ui that already has a way to show documentations by providing multiple json files

I think this is still valid question because this project works by scanning files/folders annotations. Your solution would work if these API's would have completely different definitions and endpoints but what if i want to share the same model definition in both API's? I cant write 2 annotations so each API would read one of them? I'm currently wondering as well how to fix this.

And you can do it indeed, just use a "Common" folder where you put files with common annotations and put such folder in both the "paths to scan" params you'll use to generate the two different json files.
You'll then be able to refer to such annotations on both the API definitions

Related #362, #415

Try writing a plugin that uses custom properties
For example: x-internal-only=true and x-external-only=true

What we do at my company (where we basically have a "customer auth api", a "guest api" and an "internal api") is just to generate multiple json files with different path to scans. Some definitions are shared in a "common" namespace between all the apis some are not (like the endpoint definitions and some specific definitions).
No use of x-internal-only (that would be limiting for our use case) and It works fairly well for us.
The result is having multiple json files that can be used to back up swagger-ui or any other json spec service.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aqlx86 picture aqlx86  路  3Comments

phansys picture phansys  路  5Comments

hpatoio picture hpatoio  路  3Comments

mikylucky picture mikylucky  路  4Comments

DerManoMann picture DerManoMann  路  3Comments