Skip to content

Implementing expand system for commons#19

Merged
Samuelfaure merged 6 commits into
developfrom
commons
Apr 15, 2026
Merged

Implementing expand system for commons#19
Samuelfaure merged 6 commits into
developfrom
commons

Conversation

@Samuelfaure
Copy link
Copy Markdown
Contributor

@Samuelfaure Samuelfaure commented Apr 9, 2026

Ajout du systeme + quelques quick-wins de refacto

related https://github.com/datagouv/

testé en sandbox

Copy link
Copy Markdown
Member

@skelz0r skelz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que je n'ai pas été très clair dans ma proposition: le but du expand.txt est justement de faire des liens symboliques, de bouger le fichier, et rien d'autre.

Si on prends authorizations.yml par exemple, on veut clairement le laisser dans siade/config/ via un lien symbolique, et on laisse le script de déploiement l'expand, i.e. le copier dans config/ au déploiement.

L'objectif était de faire des modifications minimal pour garder du code simple.

Comment thread siade/app/models/scope.rb Outdated
@skelz0r
Copy link
Copy Markdown
Member

skelz0r commented Apr 11, 2026

Pour clarifier ma review, la mécanique est OK, juste le expand.txt n'est pas assez bien utilisé (notamment en prenant l'exemple du authorizations.yml

@Samuelfaure
Copy link
Copy Markdown
Contributor Author

J'ai revert les changements relatifs à authorizations.yml - pour les fichiers swagger ça me semble OK comme ça ?

Copy link
Copy Markdown
Member

@skelz0r skelz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que c'est good enough, en lisant je pense qu'on pouvait faire un truc plus intelligent du style:

source:destination

Et du coup par exemple pour authorizations.yml

../commons/authorizations.yml:config/data/authorizations.yml

Et là on aurait eu des changements minimaux et standard dans le code, qui devrait être en vrai la cible de cette PR.

(au passage, j'aurais nommé ça .expand in fine pour éviter d'avoir un .txt)

C'est pas critique, donc tell me si tu veux un approve, mais si tu fais l'effort je suis preneur.

@Samuelfaure
Copy link
Copy Markdown
Contributor Author

Je vais faire l'effort ;D

Samuelfaure and others added 6 commits April 15, 2026 10:03
--documentation takes way too long
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SIADE now generates those files in commons/, the single source read by
siade/, site/, and mocks/. Each app exposes the files at their original
in-app path via a file-level symlink committed in git, so app code keeps
reading from its usual path. At deploy time each app's .expand file
materializes the real files at those destinations via the
source:destination format.

site/config/api-particulier-openapi-v3.yml, which was an unused
duplicate of commons/swagger/openapi-particulier.yaml on develop, is
also converted to a symlink so the site only ever reads one canonical
v3 definition.
siade/config/authorizations.yml is now a symlink to
commons/data/authorizations.yml, shared with mocks (which previously
kept its own divergent copy at mocks/data/siade_authorizations.yml).
Mocks generates JWT tokens from this file, so keeping two copies meant
scope drift between the real API authorization rules (siade) and the
staging tokens (mocks); this is now a single source of truth.

- siade/config/authorizations.yml is a symlink to
  ../commons/data/authorizations.yml so existing code (config_for,
  generators, etc.) works without changes.
- siade/.expand adds
  commons/data/authorizations.yml:config/authorizations.yml so the
  deploy script materializes the real file at the in-app path.
- mocks/bin/generate_token.rb reads via mocks/commons symlink.
- siade docs and CLAUDE.md updated.
Now that siade, site and mocks live in the same repository and share
commons/swagger/ (generated by siade), there is no reason to keep the
remote-fetch code paths that existed when each app was standalone.

site:
- AbstractOpenAPIDefinition no longer has remote_url / load_local? /
  URI.open fallback. Subclasses just declare a local_path Pathname and
  the abstract class reads it.
- APIEntreprise/APIParticulier open-api definition services collapsed
  to local file reads from their config/api-*.yml paths (which are
  symlinks to commons/swagger/ in dev, and materialized from commons/
  on deploy via .expand).
- Removed the four WebMock stubs that faked responses from
  entreprise.api.gouv.fr and particulier.api.gouv.fr open-api URLs;
  nothing hits those URLs anymore.
- Removed the LOAD_LOCAL_OPEN_API_DEFINITIONS=true invocation from
  README and CLAUDE.

mocks:
- lib/open_api_helpers.rb: dropped the ENV['LOCAL'] switch,
  load_schema_from_remote, the $remote_schemas global, and the
  open-uri require. load_schema unconditionally reads from
  commons/swagger/.
- README: the paragraph about LOCAL=true is now a statement that
  commons is the source.
Copy link
Copy Markdown
Member

@skelz0r skelz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup avec le nouveau système et le fait que les liens symboliques existent en local, modulo la modification du système de backend mocks et la suppression des swagger en doublon il n'y a rien à changer non ?

Copy link
Copy Markdown
Member

@skelz0r skelz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce qui m'a l'air d'être le cas j'ai mal lu 😅

@Samuelfaure Samuelfaure merged commit 8abb232 into develop Apr 15, 2026
24 checks passed
@Samuelfaure Samuelfaure deleted the commons branch April 15, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants