We have a use-case where we have to manually write and validate the Swagger in OpenAPI spec 2.0 standard. At the moment, we have to use Swagger Editor UI locally to copy and paste the Swagger before checking in our code.
We're looking for an npm package that does it for us which we can potentially use as husky pre-hook for it to raise warnings or errors if there's anything wrong with the Swagger.
To note, the kind of validation we're looking for is as follows:
items not defined under array should raise an error
properties not defined under items should raise an error
and so on.
Related
I know that SvelteKit is still in beta and changing a lot, but I'd still like to ask about getting TypeORM to work with the SvelteKit dev server and production node server.
I made a minimal repository with a basic SvelteKit project (using npm init svelte#next) and TypeORM (using installation instructions here).
When I try to do npm run dev -- I get a warning that import-metadata isn't importing correctly:
reflect-metadata doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.
Then I get an exception from TypeORM:
[vite] Error when evaluating SSR module /src/lib/User.ts:
ColumnTypeUndefinedError: Column type for User#id is not defined and cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true option in tsconfig.json. Also make sure you have imported "reflect-metadata" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.
I'm not sure why the reflect-metadata library doesn't seem to be importing correctly. I've tried both import "reflect-metadata" and import * as Reflect from 'reflect-metadata'; but got the same error. Heck, I even tried copying and pasting the JS library into hooks.ts and commenting out the imports, but the same reflect-metadata and TypeORM errors seem to happen.
Right now my assumption is that if the reflect-metadata library can be imported correctly then that would fix the TypeORM error, but I'm not sure. Here's a relevant issue in the SvelteKit Github and here's a reddit thread I made without much help. I'm hoping that my issue can be solved without opening a new SvelteKit issue but I want to make sure that it's possible to use TypeORM with SvelteKit since it's the most starred JS ORM on Github.
If you have any ideas or solutions I'd love to hear them!
(Sample) Problem:
When a yaml source contains conflicting definitions, e.g. myClass and MyClass both generating into a java class MyClass with one overwriting the other, no warning or error occurs.
Other similar cases can occur the same way (e.g. via implicitly generated classes from complex entries of type: array).
Framing
has to work without modifying the source file
there is exactly one source file, for whatever that's worth
has to work as a Maven plugin
tested with swagger-codegen-maven-plugin 2.4.0 and 2.4.22
am familiar with JAXB2 and both of its common Maven plugins:
jaxb2-maven-plugin
maven-jaxb2-plugin
am not familiar with swagger-codegen-maven-plugin
did not find solutions (or even corresponding problem reports) using Google searches
swagger codegen strict
swagger-codegen-maven-plugin strict
swagger codegen name collision
swagger-codegen-maven-plugin name collision
swagger codegen resolve name collision
swagger-codegen-maven-plugin resolve name collision
found this closed issue describing a similar issue (silently generates corrupt code), which appears to be mostly unrelated and is alledgedly long fixed
Question
What is the proper solution that produces
an eagerly failing generation process
amended via externally configured customBindings
without touching the yaml source file
?
Solution ideas:
Use JAXB2 instead
JAXB2
fails generation where a generated file already exists
allows a separate customBindings.xjs file to modify generation of
classes
can be adapted to work with YAML using
JacksonJaxbYAMLProvider
However it seems that the common Maven plugins jaxb2-maven-plugin and maven-jaxb2-plugin do not support YAMl definition files (out of the box?). [1]
Use Mustache files to resolve the name collision
The Mustache language seems to provide the necessary facilities to implement rules similar to JAXBs xjb.
However
binding a Mustache template to a class has to be done by name (<class name>.mustache), aka. name collision in particular cannot be resolved from an external file [2]
this does not help with the silence of errors in generated code - one cannot fix the error, while unaware of it
1 - Searches for this topic have yielded one result that it does not work out-of-the-box (duh) and no results whether it can be made to work using the extensions interface both plugins support.
2 - I could not find the relevant part directly within Swagger codegen documentation, but here is a relevant part of the implemented-by-Swagger OpenAPI generator documentation.
I have a .Net Framework MVC app and I integrated DynamoDB.
When I enter on any page, until the page is fully loaded, I get many DynamoDB errors.
Does anyone know what the issue can be?
I checked a lot (found out that is related to Http Modules) but can not find any reason.
I have AWSSDK.Core (3.3.106.7) and AWSSDK.DynamoDBv2 (3.3.105.29) packages installed.
After some more investigation I find that the error is because some files are missing. Example:
Locating source for 'D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\HttpErrorResponseExceptionHandler.cs'.
The file 'D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\ErrorHandler\HttpErrorResponseExceptionHandler.cs' does not exist
But I don't even have a D:\ partition. Where is this coming from?
You're doing some operation with a condition expression and that condition isn't fulfilled, that's why you're getting a ConditionalCheckFailed exception.
From the docs:
ConditionalCheckFailedException
Message: The conditional request failed.
You specified a condition that evaluated to false. For example, you
might have tried to perform a conditional update on an item, but the
actual value of the attribute did not match the expected value in the
condition.
OK to retry? No
This is all I can tell you based on the amount of details (or lack thereof) you've provided.
As the krakend.json is not of the type which swagger understands.Following error occurs:
Error: Document must be valid OpenAPI 3.0.0 definition
Is there any alternate way to generate documentation for krakenD
Generating both KrakenD configuration and OpenAPI documentation is possible, but...
You should precisely define your use case:
Do you want to generate krakend.json config from OpenAPI just as no-op proxy? (see an example script)
Are you willing to adopt another (custom) format? (see openapi2krakend)
Do you want to generate OpenAPI documentation from KrakenD config? If so, do you need just a list of endpoints or do you want also to have defined descriptions, examples and types (!) in one file?
You should (at least try to) write the script to generate the configuration by yourself to suit your needs.
Consider a usage of KrakenD Studio that has the OpenAPI generator plugin.
It can look like a good idea, but the devil is in the details and you should analyse your requirements because these two files have totally different purposes. I can only suggest you write such a transformation script (as I did) which should be like "5 minutes of work" and then go to the deep.
Edit: We have selected a subset of KrakendD features and implemented our own configuration generator (from OAS). We use tags with a custom route-to/ prefix for metadata, a definition could look like this:
/coupons/{id}:
get:
tags:
- Coupons
- route-to/path=/coupons/{id}/detail
- route-to/backend=GET|http://coupons.content
- route-to/flags=jwt_validation
i'm trying to use swagger-codegen-maven-plugin to generate my interface .
after compiling with the plugin - it generates all the files correctly but for some reason
the interface name is DefaultApi.
i looked for some configuration that i can change the name of the interface that been generated but didnt find the solution for that.
any idea on that??
"DefaultApi" is used when there's no tags specified for the endpoint.
For example, this endpoint will be put in a class named "UserApi" since the tags is set to User.
You will need to update the spec to include proper tags for endpoints to avoid using "DefaultApi"
UPDATE: On May 2018, about 50 top contributors and template creators of Swagger Codegen decided to fork Swagger Codegen to maintain a community-driven version called OpenAPI Generator. Please refer to the Q&A for more information.