Comments (6)
Ok i commented customMethods and it work, but when I add back customMethods my doc options are not readed again
Update:
I found that If I instanciate customMethodsHandler before cors or other things, it fail so I assume it's not a real bug mostly me being a noob
from feathers-swagger.
Hi @SoxZz5,
you did exactly right, by setting it via operations like you did here:
const heroSwaggerOptions = () =>
createSwaggerServiceOptions({
schemas: { heroSchema, heroQuerySchema, heroDataSchema, heroPatchSchema },
docs: {
description: 'Endpoint to get informations on heroes',
securities: [],
operations: {
get: {
summary: 'Test'
},
find: {
summary: 'Test'
}
}
},
});
I have checked that this works for me and it does.
As you only show the code to create the swagger options, my question would then be, how do you use the result of it?
Or does the rest work, like your custom description and the set schemas?
from feathers-swagger.
I then use it in the service directly like this :
export const hero = (app: Application) => {
app.use(heroPath, new HeroService(getOptions(app)), {
methods: heroMethods,
events: [],
docs: heroDocs,
});
// Initialize hooks
app.service(heroPath).hooks({
around: {
all: [
schemaHooks.resolveExternal(heroExternalResolver),
schemaHooks.resolveResult(heroResolver),
],
},
before: {
all: [
schemaHooks.validateQuery(heroQueryValidator),
schemaHooks.resolveQuery(heroQueryResolver),
],
},
after: {},
error: {},
});
};
And swagger is init like this :
const app: Application = koa(feathers());
// Load our app configuration (see config/ folder)
app.configure(configuration(configurationValidator));
//Set up documentation custom methods handler before Koa middleware
app.configure(swagger.customMethodsHandler);
// Set up Koa middleware
app.use(cors());
app.configure(rateLimiter);
// Removed cause we don't want to have a frontend for feather
//app.use(serveStatic(app.get('public')))
app.use(errorHandler());
app.use(parseAuthentication());
app.use(bodyParser());
// Configure services and transports
app.configure(rest());
//Set up configuration for swagger
app.configure(
swagger({
specs: {
info: {
title: 'FantasyTop API',
description: 'FantasyTop API powered by feathers',
version: '1.0.0',
},
},
})
);
app.configure(feathersCasl());
app.configure(
socketio({
cors: {
origin: app.get('origins'),
},
})
);
app.configure(postgresql);
app.configure(services);
app.configure(channels);
// Register hooks that run on all service methods
app.hooks({
around: {
all: [logError],
},
before: {},
after: {},
error: {},
});
// Register application setup and teardown hooks here
app.hooks({
setup: [],
teardown: [],
});
export { app };
I give you all the code for better comprehension hope it would help
Btw thanks for your rapid answer
from feathers-swagger.
The description doesn't work too I did a try by adding this :
docs: {
description: 'Endpoint to get informations on heroes TGETATT',
securities: [],
operations: {
find: {
summary: 'test',
},
get: {
summary: 'test',
},
},
tags:
- name: hero
description: Endpoint to get informations on heroes
from feathers-swagger.
From what I see the problem could be that you create a function that returns the result instead of using it, the docs property needs to be an object.
const heroSwaggerOptions = () =>
createSwaggerServiceOptions({
...
});
const heroDocs = heroSwaggerOptions(); // Do you do this, or is this missing?
app.use(heroPath, new HeroService(getOptions(app)), {
methods: heroMethods,
events: [],
docs: heroDocs,
});
I usually do
app.use(heroPath, new HeroService(getOptions(app)), {
methods: heroMethods,
events: [],
docs: createSwaggerServiceOptions({ ... }),
});
but of course, it should be no problem to provide the result of createSwaggerServiceOptions in a different way.
from feathers-swagger.
Last update to close it, I also got a lot of problem with bun cache, when I call localhost:3030 that's ok, but when I call my generate script I got problem, but no worry it's fixed on my side thanks for your fast answer,
I will have many other question in the futur I pushed my doc on redocly and I'm not really feeling happy with what it generated but it maybe also about how I used feathers, so before asking will try to figure out
from feathers-swagger.
Related Issues (20)
- Feature: Add support for multi create
- Feature: Add support for pagination
- Feature: Respect x-forwarded-prefix header
- Support for feathers v5 (Dove) HOT 9
- Error: Invalid service object passed for path `docs` HOT 3
- Feature: Support koa
- Feature: Support dove custom methods
- Feature: Create documentation for services with schemas of Feathersjs dove (v5)
- Documentation: Use docsify for documentation
- Bug: Can't access ID in path HOT 2
- Feature: Handle Type.Literal HOT 7
- Bug: Custom method definitions are effecting other methods HOT 1
- Feature: Documentation is only generated for methods provided via service options
- How can I get correct prefix with $ref in related models? HOT 2
- Bug: Documentation for Usage with SwaggerUI
- Static generation HOT 1
- Feature: ESM module HOT 7
- How to stop autogeneration of swagger-json HOT 1
- Swagger sequelize schema generation HOT 2
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 feathers-swagger.