Comments (8)
@christianhelle It seems that NSwag has some issues with $ref. Refitter can find other OAS files but failed on processing other files' $ref field. So maybe we can load all OAS files and combine them into a single file, and then send it to refitter gengrator. It's similar to preprocessing, and it can make NSwag to correctly handle the following steps.
from refitter.
@christianhelle This is already sufficient for my usage scenario, thank you!
from refitter.
@naaeef thanks for taking the time to report this
I was unaware of this feature in the OpenAPI spec. Do you have an example spec that does this? I use NSwag to parse the OpenAPI spec, it might even already be supported out of the box, but I don't know
from refitter.
@christianhelle Hello,
I have the same suggestion. Here I have an example using separate files. Please see this repo. All the schemas are defined in components.yaml while request pathes in openapi.yaml. I hope this may helpful, thanks.
from refitter.
@christianhelle Hello, I have the same suggestion. Here I have an example using separate files. Please see this repo. All the schemas are defined in components.yaml while request pathes in openapi.yaml. I hope this may helpful, thanks.
@kami-poi Thanks for the example. This will be a big help!
I'll see what I can do over the holidays
from refitter.
@kami-poi I was looking into this today using the repo you provided and it seems like NSwag just doesn't support multiple OAS files. I'll experiment with how far I can get with using the Microsoft OpenAPI toolchain
OpenAPI validation seems to work fine and prints out
OpenAPI statistics:
- Path Items: 32
- Operations: 46
- Parameters: 7
- Request Bodies: 21
- Responses: 46
- Links: 0
- Callbacks: 0
- Schemas: 67
I would hate to have to generate the contracts by hand using the MS OpenAPI toolchain since this is already a solved problem by NSwag
from refitter.
@christianhelle It seems that NSwag has some issues with $ref. Refitter can find other OAS files but failed on processing other files' $ref field. So maybe we can load all OAS files and combine them into a single file, and then send it to refitter gengrator. It's similar to preprocessing, and it can make NSwag to correctly handle the following steps.
@kami-poi This is exactly what I ended up doing!
C:/projects/christianhelle/refitter/src/Refitter/bin/Release/net8.0/refitter.exe C:\projects\github\bot-oas\v1\openapi.remote.yaml
Refitter v1.0.0.0
Support key: ptbddgt
OpenAPI specifications contains external references.
Attempting to merge of all external references into single document...
components.yaml - Paths must be a map/object
components.yaml - The field 'paths' in 'document' object is REQUIRED.
OpenAPI statistics:
- Path Items: 32
- Operations: 46
- Parameters: 13
- Request Bodies: 21
- Responses: 46
- Links: 0
- Callbacks: 0
- Schemas: 210
Length: 90275 bytes
Output: C:\projects\christianhelle\refitter\src\Refitter\bin\Release\net8.0\Output.cs
Duration: 00:00:02.5172435
Currently, it supports having external references to files within the same folder, or remotely. But it won't work if the remote file has local external references.
These scenarios work:
- The OAS file
/home/christian/openapi.yaml
has external references tocomponents.yaml
then I expectcomponents.yaml
to be in the same folder as/home/christian/openapi.yaml
. - The OAS file
/home/christian/openapi.yaml
will also work if it has external references tohttps://somewhere.over.the.rainbow/components.yaml
This scenario doesn't work:
- The OAS file
https://somewhere.over.the.rainbow/openapi.yaml
has external references tocomponents.yaml
If you can live with this @kami-poi @naaeef then I will merge in my working solution to the main branch and publish a release
from refitter.
@kami-poi @naaeef I released a preview version as version 0.8.7.41-preview
containing the fix for this
You can install it with
dotnet tool install --global Refitter --version 0.8.7.41-preview
I'll bundle a few other fixes before I do a full release
from refitter.
Related Issues (20)
- Hyphens with JsonStringEnumConverter results in `JSON value could not be converted` HOT 7
- Response is always nullable under `generateNullableReferenceTypes` HOT 2
- Source generator does not work in .Net 8 HOT 1
- Support for OpenAPI version 3.1.0 HOT 2
- Non string/boolean CodeGeneratorSettings are not honored HOT 3
- Generate the client from multiple versions HOT 1
- `remove-unused-schema` not working for collection-type responses HOT 1
- Asana API "cannot derive from sealed type" HOT 4
- Code Generator creates unsafe interface method names HOT 1
- Code Generator adds numeric suffix to Interface method name when not needed HOT 3
- Add the facility to exclude namespaces from generated code HOT 5
- Asana API specs strange naming HOT 2
- Refit Fails on Jira OpenAPI specs HOT 5
- Serializer improvements HOT 1
- All Contributors Bot HOT 12
- Polly.Extensions.Http deprecated in favour of Microsoft.Extensions.Http.Resilience HOT 3
- Support generating immutable records HOT 8
- AnyType + BodySerializationMethod HOT 4
- Support generating multiple files HOT 2
- Support custom format-mappings via Key-Value configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refitter.